CGI Perl Question:

Download Job Interview Questions and Answers PDF

How to sort dates in Perl?

CGI Perl Interview Question
CGI Perl Interview Question

Answers:

Answer #1
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;

Answer #2
@sortDates = sort { join(\\'\\',(split\\'/\\',$a)[2,1,0] ) <=> join(\\'\\',(split\\'/\\',$b)[2,1,0])} @mydates;

Download CGI Perl Interview Questions And Answers PDF

Previous QuestionNext Question
Packing and Unpacking.

Hi, I want to get output as 0x23400000345....
in the below example How to get?
i tried out, but unable to get the answer

$r=0x234;
$t=0x345;
$y=pack(L L,$t,$r);
$x1=unpack(L!,pack(P,$y));
printf("nThe value is $x1");

I didnt get constant output?
Sort a word "system" in perl/shell without using built in functions output should be emssty?