in reply to Code Review on Several Interesting Points

Another way to handle $/ is to localize it within a block (which is kind of silly in this case, since the function is so short, but here it is as an example). Localizing a variable also sets it to undef, so that additional assign is redundant.

It often helps to know why an open fails, so printing $! helps. The error messages are usually verbose enough to render "can't open" redundant.

sub scanfile ($) { my $filename= shift; open my $handle, '<', $filename or croak "[$filename] $!"; return do { local $/; scan(<$handle>) }; }