Ed Avis <eda <at> waniasset.com> writes:
>>>>To this day, Perl's implicit closing of files doesn't warn you of
>>>>errors, let alone exit nonzero. This makes it do wrong thing and not
>>>>even tell you it did them wrong.
>If I might play devil's advocate for a moment:
>
>The manual page clearly states that it ignores errors on close and always has
>done. Here's the perl1 manpage;
Obviously, I made a mistake here: I should have quoted from perlrun(1):
#!/usr/bin/perl
$extension = '.orig';
LINE: while (<>) {
if ($ARGV ne $oldargv) {
if ($extension !~ /\*/) {
$backup = $ARGV . $extension;
}
else {
($backup = $extension) =~ s/\*/$ARGV/g;
}
rename($ARGV, $backup);
open(ARGVOUT, ">$ARGV");
select(ARGVOUT);
$oldargv = $ARGV;
}
s/foo/bar/;
}
continue {
print; # this prints to original filename
}
select(STDOUT);
The point still stands. It's pretty 'obviously' documented that -i does not
check close(). Just as 'obvious' as that <> will sometimes go off and run
commands, overwrite things or open the wrong file.
--
Ed Avis <eda@waniasset.com>
Thread Previous