in reply to my $var = ''; vs. use constant VAR => '';
The second method is better defensive programming. However, what it does is pretty much equivalent to the following:
Because FILENAME is actually a subroutine, it cannot be interpolated in quotes. In other words, the following are not synonymous:BEGIN { sub FILENAME() { '/path/to/file/to/munge' } }
The first example prints the filename, the second just prints "FILENAME".my $filename = "/path/to/file/to/munge"; print "$filename"; use constant FILENAME => '/path/to/file/to/munge'; print "FILENAME";
That's a minor issue, but it does crop up from time to time (particularly when I'm writing an open X, Y or die statement).
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.
|
---|
In Section
Seekers of Perl Wisdom