-----Original Message----- >From: [EMAIL PROTECTED] >Sent: May 8, 2007 9:54 PM >To: [EMAIL PROTECTED] >Cc: beginners@perl.org >Subject: Re: looping through a file
>my @lines = <$AFILE>; >foreach my $prime_id ( @id_hits ) { > foreach my $line( @lines ) { > if ( $line =~ /$prime_id/ ) { > print "$line\n"; > next; 'next' is not needed here. Also the whole thing could be written as this simple but more efficient way, sub matching { my @[EMAIL PROTECTED]; my $eval=join "||", map { "\$_[0]=~m/\$inits[$_]/o" } 0 .. $#inits; my $ref=eval "sub { $eval }"; die "can't eval: $@" if $@; return $ref; } my $match_ref=matching(@id_hits); while(<$FILE>) { print if $match_ref->($_); } Hope this helps. -- mailto:[EMAIL PROTECTED] http://home.arcor.de/jeffpang/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/