http://qs321.pair.com?node_id=1186530

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks!

I am just trying to find a less code way to do this parsing using regular expressions.
In the first one I am getting a "1", why it cant be done this way.
It works on the second code, unless there is a more efficient way of doing it.

#!/usr/bin/perl use strict; use warnings; my $adate = "2017-01-29 11:30:07.370"; # more direct way, but returning a "1". my $a_new_datetime = ( $adate =~ s/(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\ +d{2})(.*)/$2-$3-$1 $4:$5/ ); print "\n 1 - $a_new_datetime\n\n"; my $new_datetime = $adate; $new_datetime =~ s/(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2})(.*)/$2-$3- +$1 $4:$5/; print " 2 - $new_datetime\n\n";

Thanks for looking at it!