(J. Romano) wrote:
: #!/usr/bin/perl
: use strict;
: use warnings;
:
: while (glob("*"))
: {
: print "$_\n";
: }
: __END__
:
:
: I was surprised to see that the program worked as expected! (That
: is, it listed every file in my directory.) I didn't expect it to do
: that, because I didn't think that the while condition would populate
: $_ for me.
[snip]
: But if the return value of getNextNum() is not placed in $_, then
: doesn't that mean that the return value of glob() also should not be
: placed in $_? If my reasoning is correct, why does the first program
: I gave populate $_?
This is explained in the documentation for the glob function. It's got a
splash of DWIM built in.