This is the script:
#!/usr/bin/perl -w
my %last_name = qw [fred flintstone Wilma Flintstone Barney Rubble betty rubble Bamm-Bamm Rubble PEBBLES FLINTSONE];
my @keys=sort
{
"\L$last_name{$a}" cmp "\L$last_name{$b}" or
"\L$a" cmp "\L$b"
} keys %last_name;
foreach my $name (@keys)
{
printf "%-10s%-10s\n",$name,$last_name{$name};
}
The expected result should be:
fred flintstone
PEBBLES FLINTSONE
Wilma Flintstone
Bamm-Bamm Rubble
Barney Rubble
betty rubble
But the output of the script came out like below when I run it on FC4 ,PEBBLES showed first:
PEBBLES FLINTSONE
fred flintstone
Wilma Flintstone
Bamm-Bamm Rubble
Barney Rubble
betty rubble
Could any body help me ? Thanks.
#!/usr/bin/perl -w
my %last_name = qw [fred flintstone Wilma Flintstone Barney Rubble betty rubble Bamm-Bamm Rubble PEBBLES FLINTSONE];
my @keys=sort
{
"\L$last_name{$a}" cmp "\L$last_name{$b}" or
"\L$a" cmp "\L$b"
} keys %last_name;
foreach my $name (@keys)
{
printf "%-10s%-10s\n",$name,$last_name{$name};
}
The expected result should be:
fred flintstone
PEBBLES FLINTSONE
Wilma Flintstone
Bamm-Bamm Rubble
Barney Rubble
betty rubble
But the output of the script came out like below when I run it on FC4 ,PEBBLES showed first:
PEBBLES FLINTSONE
fred flintstone
Wilma Flintstone
Bamm-Bamm Rubble
Barney Rubble
betty rubble
Could any body help me ? Thanks.