warnings on sorting hash of hashes

Discussion in 'Perl Misc' started by sam, Jan 5, 2005.

  1. sam

    sam Guest

    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.
    sam, Jan 5, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott  Gilpin
    Replies:
    2
    Views:
    211
  2. Perl Learner

    Hashes of hashes or just one hash ?

    Perl Learner, Jun 8, 2005, in forum: Perl Misc
    Replies:
    11
    Views:
    207
  3. Tim O'Donovan

    Hash of hashes, of hashes, of arrays of hashes

    Tim O'Donovan, Oct 27, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    201
  4. IanW
    Replies:
    3
    Views:
    121
    Ian Stuart
    Dec 14, 2005
  5. Replies:
    3
    Views:
    198
Loading...

Share This Page