[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Re: Golf: chessboard



Mike Pullen <mpullen@midwest.net> wrote:

> I am trying to understand why --$| does what it does.  $|=0 by
> default.  --$| should subtract 1 and keep subtracting on each
> iteration.  'perlop' says -- is not magic, it does not magically
> decrement, similar to the way ++ increments.

It's true that autodecrement isn't magical, but $| is.  I can't 
find anything about it in perlvar, but it seems that $| can 
only take the values 0 and 1.  If you set it to a value that's 
numerically equal to 0 (not just a false value), then it ends 
up as 0.  If you set it to something that's numerically equal 
to something else, it ends up as 1.  Thus autodecrement causes 
it to toggle between 0 and 1.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe