in reply to Convert date into day and month

Hi,

try this:

use strict; use warnings; my $year = 2013; # hard coded as not in the data my %months = (Jan => "01", Feb => "02", Mar => "03", Other => "...4 5 +6 7 8 9", Oct => 10, Nov => 11, Dec => 12); my $line = <DATA>; my ($date, $rest) = split /,/, $line; my ($mon, $day) = split / /, $date; my $month = $months{$mon}; my $new_date = "$month$day$year"; print $new_date, "\n"; __DATA__ Oct 31 08:30,/home/imanager/cppprod/AR_LM.csv Oct 31 07:32,/home/imanager/cppprod/AddressDevCHUBldgProj.csv Oct 31 08:06,/home/imanager/cppprod/AddressDevCHUBldgProj_LM.csv Oct 31 07:44,/home/imanager/cppprod/BalDue.csv Oct 31 08:07,/home/imanager/cppprod/BalDue_LM.csv Oct 31 07:50,/home/imanager/cppprod/Charges.csv Oct 31 08:10,/home/imanager/cppprod/Charges_LM.csv Oct 31 08:45,/home/imanager/cppprod/Dem_A_C.csv
This outputs this:
$ perl dates.pl 10312013
I would suggest that you use the mkdir Perl internal function, rather that a system call. Something like this:
mkdir $new_date or die "could not create directory $new_date $!";

Replies are listed 'Best First'.
Re^2: Convert date into day and month
by Ma (Novice) on Nov 01, 2013 at 17:10 UTC
    Thank you. I appreciate very much. I have now everything needed to complete the script. I found the members of this community very very helping and knowledgeable.