in reply to Re: Re: Re: Re: Should We Have A "Red Flags" Area?
in thread Should We Have A "Red Flags" Area?

Hm, I think I'm doomed to fail with that parenthetical remark. Still, compare this program:

perl -pe -i.bak 's/PERL/Perl/g' *.txt

with this one:

perl -e 'use File::Copy;  foreach my $file (@args) { open my $fh, $file or die "Cannot open $file: $!\n";  my @lines; copy( $file, $file . ".bak"; while (defined( my $line = <$fh> )) { $line =~ s/PERL/Perl/;  push @lines, $line; } close $fh;  open $fh, '>', $file or die "Cannot write to $file: $!\n"; print $fh, @lines; }'

The first uses global variables. The second uses lexicals. I typed both straight off the top of my head, just as I would at a command line. I'm willing to bet that the first doesn't have any errors. I'll be pleasantly surprised if the second doesn't have at least one typo.

Update: Five days later, someone does spot a typo! Well done, coolmichael! (completely unintentional on my part)