N
nan li
Hello,
I have a question about glob in scalar context.
The perldoc says,
' In scalar context, glob iterates through such
filename expansions, returning undef when
the list is exhausted.'
So I wrote the following and it returns all pl files.
while ( my $f = glob "*.pl" ) {
print $f, "\n";
}
But without a loop, glob seems to give me just the first
file all the time.
my $f = glob "*.pl";
print $f, "\n"; # "first.pl"
$f = glob "*.pl";
print $f, "\n"; # "first.pl" again
Does any one have an explanation. I am confused.
Thanks,
Nan
I have a question about glob in scalar context.
The perldoc says,
' In scalar context, glob iterates through such
filename expansions, returning undef when
the list is exhausted.'
So I wrote the following and it returns all pl files.
while ( my $f = glob "*.pl" ) {
print $f, "\n";
}
But without a loop, glob seems to give me just the first
file all the time.
my $f = glob "*.pl";
print $f, "\n"; # "first.pl"
$f = glob "*.pl";
print $f, "\n"; # "first.pl" again
Does any one have an explanation. I am confused.
Thanks,
Nan