S
sam
Hi,
I got the following warnings when doing sorting a hash with hashes:
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
#!/bin/usr/perl -w
#use warnings;
my %products = (
1 => {
name => "Floor Wax",
wholesale => "50.00",
retail => "75.00",
},
2 => {
name => "Paper Towel",
wholesale => "20.00",
retail => "40.00",
},
3 => {
name => "Hand Soap",
wholesale => "30.00",
retail => "65.00",
},
);
foreach my $key (sort {$products{retail}{$a} <=> $products{retail}{$b}}
keys %products) {
print "\n<br>K|$key| N|$products{$key}{name}|
W|$products{$key}{wholesale}| R|$products{$key}{retail}|";
}
print "\n";
What is wrong with line 22 on the line of "foreach...."?
Thanks
Sam.
I got the following warnings when doing sorting a hash with hashes:
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
Use of uninitialized value in numeric comparison (<=>) at hash-hash.pl
line 22.
#!/bin/usr/perl -w
#use warnings;
my %products = (
1 => {
name => "Floor Wax",
wholesale => "50.00",
retail => "75.00",
},
2 => {
name => "Paper Towel",
wholesale => "20.00",
retail => "40.00",
},
3 => {
name => "Hand Soap",
wholesale => "30.00",
retail => "65.00",
},
);
foreach my $key (sort {$products{retail}{$a} <=> $products{retail}{$b}}
keys %products) {
print "\n<br>K|$key| N|$products{$key}{name}|
W|$products{$key}{wholesale}| R|$products{$key}{retail}|";
}
print "\n";
What is wrong with line 22 on the line of "foreach...."?
Thanks
Sam.