How to sort dates in Perl ?



How to sort dates in Perl ?..

Answer / kiruthikau

Try the following way.
Example
-------
use Data::Dumper;
my @dates = ( "02/11/2009" , "20/12/2001" , "21/11/2010" ) ;
@dates = sort { join( '', (split '/', $a)[2,1,0] ) cmp
join( '', (split '/', $b)[2,1,0]) } @dates;
print Dumper \@dates;

Is This Answer Correct ?    7 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

Which has the highest precedence, List or Terms? Explain?

0 Answers  


Explain the internal working of cgi

0 Answers  


Which functions in perl allows you to include a module file.

0 Answers  


What is the difference between use and require in perl?

0 Answers  


Does Perl have objects? If yes, then does it force you to use objects? If no, then why?

0 Answers  






Explain 'grep' function.

0 Answers  


Explain different types of perl operators.

0 Answers  


How many types of primary data structures in Perl and what do they mean?

0 Answers  


What do you mean by context of a subroutine?

0 Answers  


Which functions in Perl allows you to include a module file or a module and what is the difference between them?

0 Answers  


I have one question regarding to eval function. I know eval function is use for error checking but I am not able to understand below line. eval \'exec perl -S $0 ${1+\"$@\"}\' if 0; $0 for script name $@ set if error occur

0 Answers  


How to convert strings into an array in perl?

0 Answers  


Categories