http://qs1969.pair.com?node_id=510533


in reply to rearranging a string.new

Can also use a regex or substitution...
my $string = '20050516'; my $newstring; $newstring = $2 . $1 if $string =~ /(\d{4})(\d{4})/; warn $newstring; (my $newstring = $string) =~ s/(\d{4})(\d{4})/$2$1/; warn $newstring;
Could also use a more robust regex if desired (trivial example is /(200[012345])(\d{4})/) and depending on context.