Next | Program Repair Shop | 213 |
sub each_file { return unless -T $_ ;
print "processing $File::Find::name\n"; unless ( open F, "< $_" ) { print "Error opening file for read: $!\n"; return; }
my $s = <F>; close F; unless ( open F, "> $_" ) { print "Error opening file for write: $!\n"; return; }
$s =~ s/COLUMN1/COLUMN1/ig; print F $s; close F; }
The flow is now simple and linear
It's obvious what the error-handling blocks are doing
They can all be understood independently
Symmetry between reading and writing becomes clearer
Next | Copyright © 2002 M. J. Dominus |