hda has asked for the wisdom of the Perl Monks concerning the following question:
Wise monks!
I implore your wisdom to dispel the shadows inside me. This is possibly the silliest question a hermit can post, so I also implore your patience as well. Ever since 2005 I have successfully opened files using the following (sinful) way:
open FILE, ">", $file;Knowing that evil's way is easy and broad, and after repenting for my sins, I solemnly promised the @perl_deities that as far it is possible and reasonable I will stick to Damian Conway's Perl Best Practices ... and now I find myself banging my head against a wall, trying to understand why this works:
open (my $fh, ">", $file);(program works as expected)
but this doesn't:
open (my $fh, ">", $file) or die "Can't open $fh";"Global symbol "$fh" requires explicit package name (did you forget to declare "my $fh"?) at test.pl line 91. Execution of test.pl aborted due to compilation errors."
I am using warnings and strict pragmata as usual. Using perl 5.28.0 in Linux.
Any hint will be appreciated!
|
|---|