kum@12 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Experts,
Trying to sort the array which has a date in MMMYY format, i have given below input and my code
The array contains data as below:
APR12 MAR13 APR11 MAR12 FEB13 APR13
#!/usr/bin/env perl my (@months) = qw(APR12 MAR13 APR11 MAR12 FEB13 APR13); my @mon = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my $mon; @{$mon}{@mon} = ( 0 .. $#mon ); sub by_month { $mon->{$a} <=> $mon->{$b}; } @months = ( sort by_month @months ); print "@months\n";
gives me this error message / faulty output:
APR12 MAR13 APR11 MAR12 FEB13 APR13
I am new to perl, any ideas on this, where i am wrong
|
---|
Back to
Seekers of Perl Wisdom