On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote:
Inside the loop I check if the value is defined, so I don't care where
in the order the undefined one shows up in. I don't want to delete
undefined ones or anything...

Then you can either turn off the warnings for that section (not
advised), ignore the warnings (also not advised), or give the null
values a value.  In the following example I use 0 as the value, but it
could be any numeric value depending on where you want undefined
values to be sorted.

#!/usr/bin/perl

use strict;
use warnings;

my %h = (
       a => { val => 3 },
       b => { val => 34 },
       c => { val => 4 },
       d => { }
);

for my $key (sort { ($h{$a}{val} || 0) <=> ($h{$b}{val} || 0) } keys %h) {
       print "$key\n";
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to