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

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.

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 $

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 regardles

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: beginne

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 i