Re: Conditional replace

2008-10-24 Thread Brian
Brian wrote: John W. Krahn wrote: Brian wrote: Partial success. The value search for is normally located starting at the 35th char into the line. I split the line so it was at the beginning of a new line and replace with worked. Unfortunately the dates never changed. I will sleep on this

Re: Conditional replace

2008-10-23 Thread Brian
John W. Krahn wrote: Brian wrote: Partial success. The value search for is normally located starting at the 35th char into the line. I split the line so it was at the beginning of a new line and replace with worked. Unfortunately the dates never changed. I will sleep on this and attack it

Conditional replace

2008-10-22 Thread Brian
Hi ARGV0 will = AB7Z001 ARGV1 will = AB7Z002 ARGV2 will = 01/01/1900 I would like to read a file, locate AB7Z001 (but not AB7Z0011, so a space at position 8 in string ) Upon location of value in argv0 replace it with argv1. Then, at the first instance of a date replace it with argv2. Then, at

Re: Conditional replace

2008-10-22 Thread Rob Coops
On Wed, Oct 22, 2008 at 3:38 PM, Brian [EMAIL PROTECTED] wrote: Hi ARGV0 will = AB7Z001 ARGV1 will = AB7Z002 ARGV2 will = 01/01/1900 I would like to read a file, locate AB7Z001 (but not AB7Z0011, so a space at position 8 in string ) Upon location of value in argv0 replace it with argv1.

Re: Conditional replace

2008-10-22 Thread Brian
From: Rob Coops [EMAIL PROTECTED] To: beginners@perl.org Sent: Wednesday, October 22, 2008 3:24:12 PM Subject: Re: Conditional replace On Wed, Oct 22, 2008 at 3:38 PM, Brian [EMAIL PROTECTED] wrote: Hi ARGV0 will = AB7Z001 ARGV1 will = AB7Z002 ARGV2

Re: Conditional replace

2008-10-22 Thread brian54321uk
Rob Coops wrote: snip open (IN, +dummy.txt); @file = IN; close IN; for ( my $i = 0; $i scalar @file; $i++ ) { # loop trought the file line by line if ( $file =~ m/$ARGV0/g ) { # look for argument $ARGV0 $file =~ s/$ARGV0(\b.*)/$ARGV1$1/g; # replace argument $ARGV0 with $ARGV1 $file =~

Re: Conditional replace

2008-10-22 Thread John W. Krahn
Brian wrote: Hi Hello, ARGV0 will = AB7Z001 ARGV1 will = AB7Z002 ARGV2 will = 01/01/1900 I would like to read a file, locate AB7Z001 (but not AB7Z0011, so a space at position 8 in string ) Upon location of value in argv0 replace it with argv1. Then, at the first instance of a date replace

Re: Conditional replace

2008-10-22 Thread Brian
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',

Re: Conditional replace

2008-10-22 Thread Brian
Brian wrote: 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

Re: Conditional replace

2008-10-22 Thread Brian
Brian wrote: Brian wrote: 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 =

Re: Conditional replace

2008-10-22 Thread John W. Krahn
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

Re: Conditional replace

2008-10-22 Thread John W. Krahn
Brian wrote: Partial success. The value search for is normally located starting at the 35th char into the line. I split the line so it was at the beginning of a new line and replace with worked. Unfortunately the dates never changed. I will sleep on this and attack it again in the morning.