John W. Krahn wrote:
Brian wrote:
Hi

Hello,

<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' );

while ( <> ) {
    if ( ?^$search ? ) {
        s/^$search/$replace/;
        s!\d\d/\d\d/\d{4}!$date!
        and s!($date.*?)\d\d/\d\d/\d{4}!$1$today!;
        }
    print;
    }

__END__




John

Oops, forgot to reply to the group.
Thanks John, however I get error message:-
Can't do inplace edit without backup at check2.pl line 13
All I can find so far with google is that this is an issue under Windows, and can be resolved by specifing and extension after the -i switch, but as there is no -i switch in this script I will keep googling.
regards
Brian

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to