in reply to File modification
You don't need a 3-argument open when the open doesn't have any user input in it. And obfuscating the code doens't really help either, even if the result is shorter.
use strict; use warnings; my ($argact, $handle, $num); ($argact) = $ARGV[0] =~ /(\d+)/; exit if !$argact; open $handle, 'one.txt'; $_ = join '', <$handle>; close $handle; ($num) = m/(\d+)$/; if ($num != $argact) { s/(\d+)$/$argact/; open $handle, '>one.txt'; print $handle $_; close $handle; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: File modification
by liverpole (Monsignor) on Jul 07, 2006 at 18:13 UTC |
In Section
Seekers of Perl Wisdom