See comments below.<br><br><div class="gmail_quote">On Tue, Dec 22, 2009 at 8:49 PM, Joseph Werner <span dir="ltr">&lt;<a href="mailto:telcodev@gmail.com">telcodev@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hey guys [and gals],<br>
<br>
I encountered a strange Perl code phenomenon dealing with some object<br>
references, and and array of object references. Specifically, I could<br>
not shift a reference to an object off of an array of object<br>
references. More troubling, I also was unable to use the object<br>
references in a boolean context. I have written code very similar to<br>
this dozens if not hundreds of times and never encountered this type<br>
of problem...<br>
<br>
The code is all proprietary,  and the powers that be frown on release<br>
of any sort, so I will pseudo code what I am talking about. We are<br>
running Active State Perl 5.10 on a Win32 platform, if that matters<br>
<br>
my $some_parms = shift;<br>
my $objhref = get_objects($some_parms);<br>
# $objhref = {<br>
#           &#39;01&#39; =&gt; bless( {}, &#39;ASpecialObject&#39; ),<br>
#           &#39;03&#39; =&gt; bless( {}, &#39;ASpecialObject&#39; ),<br>
#           &#39;02&#39; =&gt; bless( {}, &#39;ASpecialObject&#39; )<br>
#         };<br>
<br></blockquote><div><br>Have you tried assigning anything from $objhref directly at this point?  For example, do you get an error if you try to do $myobj = $objhref-&gt;{01}?<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

# ASpecialObject class does have the &lt;=&gt; overloaded<br>
# But I cannot see the making a difference...<br>
<br>
# Sorting works fine:<br>
<br>
my @arrayoforefs;<br>
eval {<br>
   @arrayoforefs = sort { $a &lt;=&gt; $b } values %{$objhref};<br>
}<br>
# Error checks ignored<br></blockquote><div><br>Since you&#39;ve wrapped this in an eval it seems like you&#39;re expecting exceptions to be thrown.  Why ignore them?  See if there is an exception that might lead you in the right direction.<br>
<br>Also, are you able to access anything within @arrayoforefs without using an assignment?  For example what happens when you do warn &quot;arrayofrefs[0]: @arrayofrefs[0]&quot;?  Do the server crash?<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
# Server dies silently at the following statement:<br>
<br>
my $chosenO = shift @arrayoforefs;<br>
<br>
# If I do this instead:<br>
<br>
my $chosenO = $arrayoforefs[0];<br>
<br>
# Then this causes the server to silently crash:<br>
<br>
return unless $chosenO;<br></blockquote><div><br>You&#39;ve said &quot;server dies silently&quot; and &quot;silently crash&quot; but I&#39;m not clear what you mean.  Is this two different things or the same?  By &quot;crash&quot; do you mean that the server process exits with a core dump?  Is this an Apache server?  Mod_perl?  When perl &quot;dies&quot; it generates a message.  Also, in my experience when Apache dumps core it puts a message in the log but you&#39;ve said &quot;silently&quot; so perhaps something else is going on.<br>
<br>My suggestion is to code up the simplest case you can where the problem is encountered.  Strip out as much code as possible that doesn&#39;t directly relate to what you&#39;re doing.  For example, the following script can be run outside of your web server and outside of your Mason environment:<br>
<br>#!/usr/bin/perl<br><br>use strict;<br>use warnings;<br>use lib &quot;/my/code/path&quot;;<br>use ASpecialObject;<br><br>my $objects = {<br> 01 =&gt; ASpecialObject-&gt;new(),<br> 02 =&gt; ASpecialObject-&gt;new(),<br>
};<br><br>my @sorted = sort {$a &lt;=&gt; $b} values %{$objects};<br><br>#Does this result in the same problems you&#39;re having?<br>
my $chosen0 = shift @sorted;<br>print &quot;If you see this then the script is done\n&quot;;<br>__END__<br><br>You&#39;ll probably have to include some object initialization code but if you still have problems with this then you know the problem is somewhere in ASpecialObject.pm.  Then you can start stripping out the code from there to find the minimum amount of code that causes the problem.<br>
<br>-- <br>Ben<br></div></div>