Sort + Use of uninitialized value

2007-04-24 Thread yitzle
Warning message: Use of uninitialized value in numeric comparison (<=>) at ... Code: foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) { How do I fix? Should my sort function be checking for variable defined? What do I return on undefined? -- To unsubscribe, e-mail: [EMAIL P

Re: Sort + Use of uninitialized value

2007-04-24 Thread Owen Cook
On Wed, Apr 25, 2007 at 01:37:24AM -0400, yitzle wrote: > Warning message: > Use of uninitialized value in numeric comparison (<=>) at ... > > Code: > foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) { perhaps foreach (sort { $dHash{$b}{'VAL'} <=> $dHash{$a

Re: Sort + Use of uninitialized value

2007-04-25 Thread Chas Owens
On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote: Warning message: Use of uninitialized value in numeric comparison (<=>) at ... Code: foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) { How do I fix? Should my sort function be checking for variable defined? What do I return on

Re: Sort + Use of uninitialized value

2007-04-25 Thread yitzle
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... On 4/25/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote: > Warning message: > Use of uni

Re: Sort + Use of uninitialized value

2007-04-25 Thread Tom Phoenix
On 4/24/07, yitzle <[EMAIL PROTECTED]> wrote: Warning message: Use of uninitialized value in numeric comparison (<=>) at ... Code: foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) { How do I fix? Give it an initialized value. Maybe like this? sort { ($dHash{$b}{VAL} ||

Re: Sort + Use of uninitialized value

2007-04-25 Thread Chas Owens
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

Re: Sort + Use of uninitialized value

2007-04-25 Thread Rob Dixon
yitzle wrote: On 4/25/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote: Warning message: Use of uninitialized value in numeric comparison (<=>) at ... Code: foreach (sort { $dHash{$b}{'VAL} <=> $dHash{$a}{'VAL'} } keys %dHash) { How do I fix? Should my

Re: Sort + Use of uninitialized value

2007-04-25 Thread Rob Dixon
yitzle 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... On 4/25/07, Chas Owens <[EMAIL PROTECTED]> wrote: On 4/25/07, yitzle <[EMAIL PROTECTED]> wrote: > Warning messag

Re: Sort + Use of uninitialized value

2007-04-25 Thread yitzle
In that case just create a list of the keys with a defined VAL value before you do the sort: my @keys = grep defined $dHash{$_}{VAL}, keys %dHash; foreach (sort { $dHash{$b}{VAL} <=> $dHash{$a}{VAL} } @keys) { print $_, "\n"; } HTH, Rob This solution appeals to me. I'll use it. Tha

Re: Sort + Use of uninitialized value

2007-04-25 Thread Rob Dixon
yitzle wrote: P.S. What's HTH? Hope This Helps :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/