in reply to Using regular expressions on user input w/o while: unitialized value

Both your while loop and your pattern match are using $_ implicitly. This line: while (<>) {is equivalent to: while (defined($_ = <>)) {Similarly, if (/foo/) {is equivalent to: if ($_ =~ /foo/) {Change to using an explicit variable and you should be OK. Look at perlsyn for more details.

Replies are listed 'Best First'.
Re: Re: While loop and pattern match (was Re: need help)
by WarrenBullockIII (Beadle) on Jun 05, 2002 at 22:39 UTC
    thanks VSarkiss
      Or you can keep the implicit match, if you add the explicit assignement to $_ before. :-) Which sometimes makes the code briefer and therefor easier to read, and sometimes makes it too short in the wrong place and therefor harder to read. (As a beginner, you should probably stick to the explicit syntax for a while.)

      Makeshifts last the longest.