From: Andrew K. <and...@ub...> - 2008-04-06 11:02:53
|
Hi, Attached is a patch that drops use of the FileHandle module and uses anonymous filehandles assigned to lexical references instead (see perldoc -f open ). It uses a more secure 3 argument call to open, and slurp mode instead of joining the lines read from files. The syntax used for this is like: if (open my $fh, '<', $filename) { $content = do { local $/; <$fh> }; close $fh; } Also a test for file readability is skipped before opening it for reading; if the file isn't readable the open fails with the same result. The PLUGINS directory handle is localized and a redundant $fh->close is removed. Some concern have been raised about the readability of dropping FileHandle, so some discussion may be in order. I don't think its too bad and its easier on the Perl runtime. To use IO::File would be more costly than FileHandle, so if the maintainers would prefer this change with tightly scoped FileHandle instances, let me know and I'll resubmit. Currently the first test in the suite fails for me, I assume that test is broken, and I've checked that this change fails that test identically. Cheers, Andrew Kirkpatrick |