in reply to Re^3: regex question
in thread regex question
In this script, it's doing it but it's changing the value rather than position. What i mean is,s/$2/something/
I wanted this to change the value of position $2, Therefore wanted to see[root@myserver tmp]# cat perl.test #!/usr/bin/perl -w use strict; my $string = "123 123 345"; if ("$string" =~ /(\d+)\s+(\d+)\s+(\d+)/) { $string =~ s/$2/something/; print "$string\n"; } [root@myserver tmp]# ./!$ ./perl.test something 123 345
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: regex question
by johngg (Canon) on Nov 12, 2007 at 19:21 UTC |