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

Re: [FWP] Re: Golf: chessboard



Rick Klement <rklement@pacbell.net> writes:

> Ton Hospel wrote:
> > 
> > $_=pop;s/\d/$|x$&/eg;s/./--$|?$&||$":$&||"."/eg;y|/|\n|;print
> 
> Cool use of a toggling variable, though.

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.

$| is evaluated in a boolean context, right?  Evidently, '--' can toggle the state of a
boolean.  But how did you figure this out?  I can't find it in the documentation.

-- 
Mike Pullen
http://www.midwest.net/scribers/mpullen

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