in reply to Code Review on Several Interesting Points

The file will automatically be closed when there are no more references in memory to the filehandle. In your code snippet above, this occurs when scanfile() returns. However, if you had return $handle; at the end of your sub, then the filehandle would be returned to the calling code, and the file wouldn't be closed at that point.

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.