Why '' Is Matched First Time, Not Second Time

From: http://links.i6networks.com (SaveWorldFromAids_at_alexa.com)
Date: 08/21/04


Date: Sat, 21 Aug 2004 00:34:00 GMT


##################Perl File
    my @line=(); my $foundcat=0;
    my $keyword1=''; my $keywordcat='';
    open ($INPUT, 'ostkall.txt') || die "can't open $file: $!";
    while (<$INPUT>) {
        chomp;
        if (!($_=~ m/.+\|.+\|.+/)) {
  if
   ($_=~ m/$keywordcat/i)
  {
   $foundcat=1;
   print "FOUND $_\n";

  } else {$foundcat=0;}
 } #end of if (!($_=~ m/.+\|.+\|.+/)

    }
    close($INPUT) ;

#####################The output is
FOUND Computers & Printers|Monitors

But it should be
FOUND Computers & Printers|Monitors
FOUND Computers & Printers|Priners

#################the data in ostkall.txt is
Computers & Printers|Monitors
 | | | | |
Computers & Printers|Printers
 | | | | |

############# Question
Empty String '' is matched the first time but not the second time. Why?



Relevant Pages