Re: sort {} to work with undef values when its expecting an object

2006-04-26 Thread JupiterHost.Net
Tom Phoenix wrote: On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects But sometimes $a-part('Name') returns undef, so the sort fails.

sort {} to work with undef values when its expecting an object

2006-04-25 Thread JupiterHost.Net
Hello List, I have a sort() issue that is a bit odd and any input wouls be most appreciated :) The code: use strict; use warnings; ... for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined }

Re: sort {} to work with undef values when its expecting an object

2006-04-25 Thread Jay Savage
On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is defined

RE: sort {} to work with undef values when its expecting an object

2006-04-25 Thread Timothy Johnson
Just a thought, but couldn't you put the logic in your grep statement? Something like this: grep {defined($_-value()) or defined($_-part('Name')-value())} @objects; -Original Message- From: JupiterHost.Net [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 25, 2006 12:22 PM To:

Re: sort {} to work with undef values when its expecting an object

2006-04-25 Thread JupiterHost.Net
Timothy Johnson wrote: Just a thought, but couldn't you put the logic in your grep statement? Something like this: grep {defined($_-value()) or defined($_-part('Name')-value())} @objects; The only problem is then that the object woudl be completely skipped. I need all objects regardless

Re: sort {} to work with undef values when its expecting an object

2006-04-25 Thread JupiterHost.Net
Jay Savage wrote: On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: for my $obj( sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects ) { ... $a/$b-value() always works since if $a/$b is

Re: sort {} to work with undef values when its expecting an object

2006-04-25 Thread Tom Phoenix
On 4/25/06, JupiterHost.Net [EMAIL PROTECTED] wrote: sort { $a-value() cmp $b-value() || $a-part('Name')-value() cmp $b-part('Name')-value() } grep { defined } @objects But sometimes $a-part('Name') returns undef, so the sort fails. I need all