PetaMem has asked for the wisdom of the Perl Monks concerning the following question:
I've stumbled across the following code:
It seems unelegant and unrobust to me, so I investigated a little bit further. To my surprise I found a strange behaviour of glob, when a glob is given that does not match but that does not contain wildcards also. Given the folowing examples:my $mask = shift; my @folders = glob("$mask"); if (scalar(@folders) == 0) { return undef; }
assume you have the files file1 and file2 in the directory glob is searching, the returns are 'file1' for @t1, '1' for @t2, 'file2' for @t3 and the empty list for @t4.@t1 = glob('*1'); @t2 = glob('1'); @t3 = glob('file2'); @t4 = glob('*3');
The behaviour for @t2 is what seems odd/annoying. In my opinion it should be empty, as the current semantics make it indistinguishable from the @t3 case - which is correct imho.
Please tell me, that I've found a bug that is soon to be fixed... :-}
Bye
PetaMem
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Isn't glob annoying? (somehow)
by dada (Chaplain) on Aug 02, 2002 at 11:07 UTC | |
|
Re: Isn't glob annoying? (somehow)
by Courage (Parson) on Aug 02, 2002 at 08:49 UTC | |
by PetaMem (Priest) on Aug 02, 2002 at 09:02 UTC | |
by Abigail-II (Bishop) on Aug 02, 2002 at 10:20 UTC | |
by Courage (Parson) on Aug 02, 2002 at 09:26 UTC |