in reply to Code Review on Several Interesting Points
open my $handle, ... will work; you'll often see it written this way. In general, my $variable can be used anywhere. Keep in mind that any other occurences of $variable in the same expression refer to the previous $variable, e.g. $variable = 7; my $variable = 1 + $variable; assigns 8 to the lexical $variable. Additionally, avoid using my $variable with a statement modifier, such as my $variable = 1 if something();. The behavior will probably not be what you expect. :)
Yes, the value of $/ has effect when <FILE> is executed, and you can change it between reads. (In Perl6, the $/ equivalent will be local to each filehandle.) BTW, local $/; undef $/; is redundant, because localizing $/ sets it to undef anyway.
I usually use single quotes to distinguish a file name in error messages, but square brackets look good.
|
|---|