Ooh good point Ben!<br><br>What is there was something else that hit the bool functionality of the object though?  It occurs to me that sorting can be a complex operation - maybe something happened when it was sorted, like this mod of your lil test script?<br>

<br><br>  1 #!/usr/bin/perl<br>  2 <br>  3 use strict;<br>  4 use warnings;<br>  5 use Carp;<br>  6 <br>  7 my @objects = sort reverse map{Snoop-&gt;new()} 1..3;<br>  8 <br>  9 # Implicit boolean context here?<br> 10 my $first = shift @objects;<br>

 11 <br> 12 # explicit boolean context here<br> 13 if ($first) {<br> 14   # nothing to do here.<br> 15 }<br> 16 <br> 17 package Snoop;<br> 18 <br> 19 use overload (<br> 20   q{bool} =&gt; sub {<br> 21         my $self = shift;<br>

 22         Carp::confess(&quot;Boolean context on objnum $self-&gt;{objnum}&quot;);<br> 23         return $self;<br> 24       },<br> 25   q{cmp} =&gt; sub {<br> 26         my $self = shift;<br> 27         my $other = shift;<br>

 28         if ($self) {<br> 29           Carp::confess &quot;Did I bool in the cmp?&quot;;<br> 30         }<br> 31         return $self-&gt;{objnum} &lt;=&gt; $other-&gt;{objnum};<br> 32      },<br> 33 );<br> 34 <br> 35 my $objnum = 0;<br>

 36 <br> 37 sub new {<br> 38   my $class = shift;<br> 39   return bless {objnum =&gt; $objnum++}, $class;<br> 40 }<br> 41 __END__                                              <br><br>That outputs for me:<br><br>Boolean context on objnum 2 at testbool line 22<br>

        Snoop::__ANON__(&#39;Snoop=HASH(0x8924c8c)&#39;, &#39;undef&#39;, &#39;&#39;) called at testbool line 28<br>        Snoop::__ANON__(&#39;Snoop=HASH(0x8924c8c)&#39;, &#39;Snoop=HASH(0x8918258)&#39;, &#39;&#39;) called at testbool line 7<br>

<br><br>One thing I&#39;ve learned for sure now is that if you&#39;re going to use the override pragma, you probably should define something for *all* of the operators/contexts - otherwise, you risk the undefined operation error all over the place!  I couldn&#39;t sort the array without defining the cmp operation...<br>

<br>But seriously, maybe thats how it happened, due to the lack of actual feedback about where the error was, it perhaps *seemed* to be on the shift when it was somewhere down in the sort?<br><br>An idea at any rate,<br>
<br>
Skylos<br><br><br clear="all">&quot;If only I could get rid of hunger by rubbing my belly&quot; - Diogenes<br>
<br><br><div class="gmail_quote">On Wed, Dec 23, 2009 at 4:07 PM, BenRifkah Bergsten-Buret <span dir="ltr">&lt;<a href="mailto:mail.spammagnet@gmail.com">mail.spammagnet@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;">

<div class="gmail_quote"><div class="im">On Wed, Dec 23, 2009 at 3:27 PM, Joseph Werner <span dir="ltr">&lt;<a href="mailto:telcodev@gmail.com" target="_blank">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;">


On Wed, Dec 23, 2009 at 2:52 PM, Skylos &lt;<a href="mailto:skylos@gmail.com" target="_blank">skylos@gmail.com</a>&gt; wrote:<br>
&gt; ...<br>
<div>&gt; Which makes me think &quot;something about that value when a shift is done uses<br>
&gt; the value in a boolean context&quot;<br>
</div>&gt; ...<br>
<br>
Thanks for the feedback Skylos, This is exactly the same conclusion<br>
that we have come too; but I STILL cannot place a boolean context in<br>
the a simple shift assignment. The powers that be crack the whip and<br>
say &quot;Problem solved, move on&quot;.   Code that does not behave the way I<br>
expect it to bothers me...<br>
<br></blockquote></div><div><br>I was considering that shift had an implicit boolean context as well so
did some digging.  Based on my test implementation it appears that
shift doesn&#39;t have an implicit boolean context.  Perhaps the boolean context is occuring after the $choosenO is returned?<br><br>Here&#39;s my test script <a href="http://is_shift_boolean.pl" target="_blank">is_shift_boolean.pl</a>:<br>


      1 #!/usr/bin/perl<br>      2<br>      3 use strict;<br>      4 use warnings;<br>      5 use Carp;<br>      6<br>      7 my @objects = map{Snoop-&gt;new()} 1..3;<br>      8<br>      9 # Implicit boolean context here?<br>


     10 my $first = shift @objects;<br>     11<br>     12 # explicit boolean context here<br>     13 if ($first) {<br>     14   # nothing to do here.<br>     15 }<br>     16<br>     17 package Snoop;<br>     18<br>     19 use overload (<br>


     20   q{bool} =&gt; sub {<br>     21         my $self = shift;<br>     22         Carp::confess(&quot;Boolean context on objnum $self-&gt;{objnum}&quot;);<br>     23         return $self;<br>     24       },<br>     25 );<br>


     26<br>     27 my $objnum = 0;<br>     28<br>     29 sub new {<br>     30   my $class = shift;<br>     31   return bless {objnum =&gt; $objnum++}, $class;<br>     32 }<br>     33 __END__<br><br>This uses the overload pragma to do the operator overloading so if you&#39;re using something else the results may be different.<br>


<br>Upon execution I got the following output:<br>Boolean context on objnum 0 at <a href="http://is_shift_boolean.pl" target="_blank">is_shift_boolean.pl</a> line 22<br>        Snoop::__ANON__(&#39;Snoop=HASH(0x814ccd4)&#39;, &#39;undef&#39;, &#39;&#39;) called at <a href="http://is_shift_boolean.pl" target="_blank">is_shift_boolean.pl</a> line 13<br>


<br>This reports only one boolean context in the if statement at line 13.  There is no report of boolean context from line 10 where the shift is.<br><br>A mystery for the ages,<br><br>-- <br>Ben<br></div></div>
</blockquote></div><br>