SPUG: Problem deleting files
tuck at whistlingfish.net
Fri Dec 1 12:14:44 CST 2000
Have we beat this one enough? ;-)
-- "Tim Maher/CONSULTIX" <tim at consultix-inc.com> spake thusly:
> Like the shells, Perl *will* do variable expansion within the
> "globbing brackets", but any wildcards have to be visible when the
> innards of those brackets are first scanned (as opposed to arising
> out of variable interpolation). Because an eval allows the
> interpolation to occur before the globbing operation is attempted, it
> allows the wildcard characters to be presented via variables.
Actually, this isn't true:
system qw(touch foo.bar foo.baz foo.bang);
my $oldfiles = 'foo.*';
my @oldfiles = < $oldfiles >;
print "Oldfiles: ", join(' ', @oldfiles), "\n";
>>>foo.bang foo.bar foo.baz http_test try try.c try.pl
>>>Use of uninitialized value in subroutine entry at >>>/usr/lib/perl5/5.6.0/i386-linux/File/Glob.pm line 145.
>>>Oldfiles: foo.bang foo.bar foo.baz
>>>http_test try try.c try.pl
So Perl apparently does do variable expansion before globbing. The important thing is still that the spaces are required. (And I wonder if
perhaps the Perl version is a factor; I'm running 5.6.0.) Although perhaps the eval trick is safer, as long as you're guaranteed to have metacharacters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/archives/spug-list/attachments/20001201/fd381b4d/attachment.bin
More information about the spug-list