|
|
|
|
|
by prakashk
4207 days ago
|
|
> $glob2 = glob(".c"); # returns the second match of "" and stores it in $glob2 Not true. $ touch 1 2 3 4.c 5.c 6.c 7 8
$ ls
1 2 3 4.c 5.c 6.c 7 8
$ perl -E '
@globvals = glob("*");
say "globvals = @globvals";
$glob1 = glob("*");
$glob2 = glob("*.c");
say "glob1 = $glob1\nglob2 = $glob2"
'
globvals = 1 2 3 4.c 5.c 6.c 7 8
glob1 = 1
glob2 = 4.c
As you can see, the third call to glob returns the expected value.Here's how glob is documented in the perlfunc document[1]. glob In list context, returns a (possibly empty) list of filename
expansions on the value of EXPR such as the standard Unix shell
/bin/csh would do. In scalar context, glob iterates through such
filename expansions, returning undef when the list is exhausted.
[1]: http://perldoc.perl.org/functions/glob.html |
|