From: Gavin C. <ga...@op...> - 2008-04-07 05:54:07
|
Hi Andrew, On Sun, Apr 06, 2008 at 08:32:54PM +0930, Andrew Kirkpatrick wrote: > 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; > } We don't actually need the close do we? I think you've used it twice and omitted it twice, so should probably do one or the other. > 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. I think readability is fine now I see the patch. The biggest issue I'd have with it is that both these open features - 3-arg open and lexical references - got added in perl 5.6, so applying this adds a 'use 5.6' requirement to blosxom. 5.6 is itself pretty ancient now, so maybe making it a requirement is reasonable. So far we have been careful about not using features like 'our' either for compatibility with ancient perls, though. What do others think? Anyone know of systems still in use that have a perl older than 5.6? Cheers, Gavin |