in reply to Using with a variable
With use strict in place, uncommenting the first line reveals that Perl thinks $pattern holds a symbolic reference, at least in the way you've used it. That's what you meant it to do, but the interpreter doesn't do two levels of interpretation.#!/usr/bin/perl -w use strict; my $pattern = "*.old"; # unlink <$pattern>; unlink <*.old>;
The first level of interpretation is looking at what is in $pattern -- *.old in this case. It stops there, instead of interpreting THAT as a glob.
The second example works because it can only be interpreted as a glob. You're just one level trickier than the Perl interpreter wants to be in this case.
|
|---|