C
clearguy02
Hi experts,
I got help earlier from here on a scrit and the final script looks as
follows. My goal is to store the new date into a vairable and use it
some where else in the perl program:
-----------------------
$date = '15-Mar-04.01:03';
%months = qw(Jan 1 Feb 2 Mar 3 Apr 4 May 5 Jun 6 Jul 7 Aug 8 Sep 9 Oct
10 Nov 11 Dec 12);
$month_lookup = join '|', keys %months;
if ( $date =~ /(\d+)-($month_lookup)-(\d+)\.(\d+)
\d+)/ )
{
printf "20%02d-%02d-%02d %02d:%02d:00\n", $3, $months{$2}, $1, $4,
$5;
}
-------------------------------
Now, instead of printing the date onto the cmd screen, I want to store
it into a variable.
When I do the following, it doesn't work:
$finalDate = printf "20%02d-%02d-%02d %02d:%02d:00\n", $3, $months{$2},
$1, $4, $5;
And $finalDate doesn't capture the date.
I also tried the below one:
printf $finalDate "20%02d-%02d-%02d %02d:%02d:00\n", $3, $months{$2},
$1, $4, $5;
Can you pl. tell me how I can store the date into a variable instead of
printing it onto the screen?
Thanks,
John
I got help earlier from here on a scrit and the final script looks as
follows. My goal is to store the new date into a vairable and use it
some where else in the perl program:
-----------------------
$date = '15-Mar-04.01:03';
%months = qw(Jan 1 Feb 2 Mar 3 Apr 4 May 5 Jun 6 Jul 7 Aug 8 Sep 9 Oct
10 Nov 11 Dec 12);
$month_lookup = join '|', keys %months;
if ( $date =~ /(\d+)-($month_lookup)-(\d+)\.(\d+)
{
printf "20%02d-%02d-%02d %02d:%02d:00\n", $3, $months{$2}, $1, $4,
$5;
}
-------------------------------
Now, instead of printing the date onto the cmd screen, I want to store
it into a variable.
When I do the following, it doesn't work:
$finalDate = printf "20%02d-%02d-%02d %02d:%02d:00\n", $3, $months{$2},
$1, $4, $5;
And $finalDate doesn't capture the date.
I also tried the below one:
printf $finalDate "20%02d-%02d-%02d %02d:%02d:00\n", $3, $months{$2},
$1, $4, $5;
Can you pl. tell me how I can store the date into a variable instead of
printing it onto the screen?
Thanks,
John