Brian wrote:
Brian wrote:
John W. Krahn wrote:
Brian wrote:
<snip>
#!/usr/bin/perl
use warnings;
use strict;
@ARGV == 3 or die "usage: $0 <search for> <replace with> <date>\n";
my ( $search, $replace, $date ) = @ARGV;
my ( $day, $mon, $year ) = ( localtime )[ 3, 4, 5 ];
my $today = sprintf '%02d/%02d/%04d', $day, $mon + 1, $year + 1900;
( $^I, @ARGV ) = ( '', 'dummy.txt' );
Oops 2!
I changed ( $^I, @ARGV ) = ( '', 'dummy.txt' );
to ( $^I, @ARGV ) = ( '.bak', 'dummy.txt' );
that got rid of the error, created a copy of dummy.txt to dummy.txt.bak
but failed to make the desired changes to dummy.txt
That's probably because the regular expression didn't match for some reason.
1 question though, while I understand why $year is + 1900, why is $mon +1 ?
perldoc -f localtime
[ snip ]
$mon is the month itself, in the range 0..11 with 0 indicating January
and 11 indicating December.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/