Rob Dixon wrote:
Robert Hicks wrote:
I decided to back up a bit and try a more simple routine. I have the
array @id_hits populated and I can search the log for the line and
print it. The problem is it only finds the first match and that is it.
foreach my $prime_id ( @id_hits ) {
while ( my $line = <$AFILE> ) {
if ( $line =~ /$prime_id/ ) {
print "$line\n";
next;
}
}
}
Do I need to pass it back to the foreach somehow?
If the IDs appear in @id_hits in the same order as in $AFILE then
you can just go and fetch the nex id to look for like this:
ID:
foreach my $prime_id ( @id_hits ) {
while ( my $line = <$AFILE> ) {
if ( $line =~ /$prime_id/ ) {
print "$line\n";
next ID;
}
}
}
but if they appear in the file in a different sequence then you also
need to rewind and start looking at the beginning of the file once
again like this:
ID:
foreach my $prime_id ( @id_hits ) {
while ( my $line = <$AFILE> ) {
if ( $line =~ /$prime_id/ ) {
print "$line\n";
seek $AFILE, 0, 0;
next ID;
}
}
}
Hope this helps.
Rob
Thanks! I was thinking about a LABEL as I just read about that the other
day.
Robert
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/