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.
I need all objects regardless of if their part call returns and object
or undef :(
Perhaps their is a logic I can do something like that, like 2 sort()s or
a map() or ??
It almost sounds like you're talking about a Schwartzian Transform. In
fact, you could process your data in steps, as the Schwartzian
Transform does. (Warning: Untested code follows.)
First, you pick out the items you want:
my @desired_data = grep { defined } @objects;
Next, transform each data item into an array reference holding the
original item and anything useful-to-know that you don't want to have
That was my first plan of attack and in fact had it all in a hash to
sort on its keys, but I discovered that the module in question does some
nice override of the object and it gets stringified in scalar context:
print $obj->value(); # prints "foo"
%lookup_table = (
obj => $obj,
...
$lookup_table{'obj'} is now the string "foo" not the object, and I've
found no way to reference it in the hash since its value is not
necessarily unique.
I'm sure I can get a good idea from your input that will help with this,
thanks!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>