in reply to Passing a $Scaler into a while loop...

It may be that what you want is:

while (defined (my $line = <WORDS>)) {

which avoids issues with values for $line that evaluate to false in a boolean context.

If that is not your problem then a better example would include some data like this:

use strict; use warnings; while (<DATA>) { chomp; my @words = split /\s+/; while (@words) { $_ = shift @words; next if ! defined $_; next unless /a/ && /e/ && /i/ && /o/ && /u/; print "Matched: $_\n"; } } __DATA__ aeiou 0 nothing here aeiou again

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Passing a $Scaler into a while loop...
by chromatic (Archbishop) on Oct 09, 2006 at 05:17 UTC

    Are you using an old version of Perl? There's an implicit defined in the scalar readline assignment; test it with B::Deparse yourself if you don't believe me:

    $ perl -MO=Deparse while (my $line = <>) {} ^D while (defined(my $line = <ARGV>)) { (); }
Re^2: Passing a $Scaler into a while loop...
by chinamox (Scribe) on Oct 09, 2006 at 04:31 UTC
    Thanks for the help!