in reply to Best way to put : between fields in a string

One-liner:
perl -e \ '$_="A3xyz45M98AB7Z9",s/(\d)([a-zA-Z])/$1:$2/gsi,print'
Using split:
use strict; my $s = "A3xyz45M98AB7Z9"; my @stuff = split(//,$s); for (my $j=0;$j<@stuff;$j++) { if ($stuff[$j] =~ /\d/ && $stuff[$j+1] && $stuff[$j+1] =~ /[a-zA-Z]/ +) { print "$stuff[$j]:"; } else { print "$stuff[$j]"; } }

I'm working on a way to make it as complicated as possible. Just because.

piroufreek