SPUG: Strange code effect

Joseph Werner telcodev at gmail.com
Tue Dec 22 20:49:13 PST 2009

Hey guys [and gals],

I encountered a strange Perl code phenomenon dealing with some object
references, and and array of object references. Specifically, I could
not shift a reference to an object off of an array of object
references. More troubling, I also was unable to use the object
references in a boolean context. I have written code very similar to
this dozens if not hundreds of times and never encountered this type
of problem...

The code is all proprietary,  and the powers that be frown on release
of any sort, so I will pseudo code what I am talking about. We are
running Active State Perl 5.10 on a Win32 platform, if that matters

my $some_parms = shift;
my $objhref = get_objects($some_parms);
# $objhref = {
#           '01' => bless( {}, 'ASpecialObject' ),
#           '03' => bless( {}, 'ASpecialObject' ),
#           '02' => bless( {}, 'ASpecialObject' )
#         };

# ASpecialObject class does have the <=> overloaded
# But I cannot see the making a difference...

# Sorting works fine:

my @arrayoforefs;
eval {
   @arrayoforefs = sort { $a <=> $b } values %{$objhref};
# Error checks ignored

# Server dies silently at the following statement:

my $chosenO = shift @arrayoforefs;

# If I do this instead:

my $chosenO = $arrayoforefs[0];

# Then this causes the server to silently crash:

return unless $chosenO;

Any help here?



More information about the spug-list mailing list