🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #14265

[perl] ¿Hay alguna forma de optimizar este bucle?

#14265
From: Gorka Olaizola
Date: Wed, 22 Nov 2000 00:00
39 lines
2113 bytes
Estoy haciendo un programa en perl y como estoy empezando no me entero de
mucho. Tengo que hacer un bucle comprobando si en el hash %subject_hash
se da algunas de las expresiones regulares de @regexp_list, pero cuando
tengo que comprobar 7000 expresiones contra 6000 titulos se eterniza.
Puede ser normal ya que son muchas comprobaciones pero quer�a saber si se
puede optimizar algo. Gracias



foreach $hash (sort keys %subject_hash) {
    $_ = $subject_hash{$hash};
    if (!(--$i & 15)) {
        print gettext("There are"), " $i ", gettext("messages left"), "\n";
    }
    foreach $key (@regexp_list) {
��������
        if (/$key/i) {
            $insert=0;
            foreach $tmp ( @articles_to_get_list) {
                if ($hash == $tmp ) {
                    $insert=1;
                    break;
                }
            }
            if ($insert==0) {
                push (@articles_to_get_list, $hash);
                print gettext("Will get article number"), " $hash ",
                      gettext("with subject"), " $_\n";
            }
        }
    }
}

-- 
  musg0 @ irc                     http://personales.jet.es/olsago/
    _-(_)-  _-(_)-  _-( )-   (o_    _-(_)-  _-(_)-  _-(_)-  _-(_)-
  `(___)  `(___)  `(___)     //\  `(___)  `(___)  `(___)  `(___)
   // \\   // \\   // \\     V_/   // \\   // \\   // \\   // \\
"Like penguins among sheeps we live." -=[Debian GNU/Linux Woody]=-
Technical Details
Message-ID: <slrn91m0va.cqa.gorka@conan.hondarribia.penguinpowered.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f86c8,a085bb156a6e9970,start
X-Google-Attributes: gidf86c8,public
From: gorka@hondarribia.penguinpowered.com (Gorka Olaizola)
Subject: [perl] ¿Hay alguna forma de optimizar este bucle?
Date: 2000/11/22
Message-ID: <slrn91m0va.cqa.gorka@conan.hondarribia.penguinpowered.com>
X-Deja-AN: 696720785
Content-Transfer-Encoding: 8bit
Organization: ecol.* (http://www.escomposlinux.org)
Content-Type: text/plain; charset=iso-8859-1
User-Agent: slrn/0.9.6.3 (Linux)
Mime-Version: 1.0
Reply-To: gorka@escomposlinux.org
Newsgroups: es.comp.os.linux.programacion