dennis, thanks for the help ! i can't remember if i thanked you before.
----- Original Message -----
Sent: Wednesday, April 26, 2000 11:54 PM
Subject: Re: redundant extraction.

You write:

open(ABC, "TEST.html") or die "Can't open TEST: $!\n";
     while ($line = <ABC>)
     {
             if ($line =~ /hello\s\d\d\d/ )
     {$hello=$&}
             if ($line =~ /E\d\d\d-\d\d\d\d/ or $line =~ /E\d\d\d\d\d\d\d/)
     {$pager=$&}
     print "$number : $hello\n";
     };

Obviously that is not your complete program because you never set $number.
But, when you read a blank line, both of the if conditions are false,
so $hello is not changed, $pager is not changed, and $number is not changed,
so you print the same information you printed for the previous line.

It is not clear to me exactly what you are trying to do, but this
might help:

open(ABC, "TEST.html") or die "Can't open TEST: $!\n";
while ($line = <ABC>)
{
    $flag = 0;
    if ($line =~ /hello\s\d\d\d/ )
        {$hello=$&; $flag++;}
    if ($line =~ /E\d\d\d-\d\d\d\d/ or $line =~ /E\d\d\d\d\d\d\d/)
        {$pager=$&; $flag++;}
    if ( $flag == 2 ) {
        print "$pager : $hello\n";
    }
};

Dennis Yelle

Reply via email to