in reply to Combining s///
Interesting question. Took me a lot longer than I expected. Did you know you can have perl statements inside your regex?
#!/usr/bin/perl for (@ARGV) { my $d; s! (\d{2})/ (\d{2})/ (\d{2}) (?{ $d = ($3 gt 55)?'19'.$3:'20'.$3;}) !$d/$1/$2!ox; print; print "\n"; }
%./foo 01/02/03 02/14/08 01/02/89 2003/01/02 2008/02/14 1989/01/02
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Combining s///
by ikegami (Patriarch) on Mar 09, 2008 at 23:39 UTC | |
by starbolin (Hermit) on Mar 10, 2008 at 07:03 UTC |