Hello monks, I'm writing a script that will simply take in a given date in the format of (DD/Mon/YYYY) where the month is entered as a 3 letters. I'm trying to convert the letters into its corresponding number using a hash but I'm having some difficulty and I know this is a simple fix but I can't seem to figure it out. Check out the code below.
#! /usr/bin/perl
print "Enter date: ";
chomp($date = <STDIN>);
($day,$month,$year) = split '/', $date;
print "$day $month $year\n";
%dates = (
'Jan' => 01,'Feb' => 02,'Mar' => 03,'Apr' => 04,'May' => 05,'Jun'
+=> 06,
'Jul' => 07,'Aug' => 08,'Sep' => 09,'Oct' => 10,'Nov' => 11,'Dec'
+=> 12,
);
foreach $char ($month){
$char =~ s/.../$dates{$month}/;
}
I keep getting compilation errors, not sure why though. Any help is appreciated.