warnings on sorting hash of hashes

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top