[oak perl] Re: [sf-perl] print Dumper \$|;
Belden Lyman
blyman at iii.com
Thu Jan 16 11:26:24 CST 2003
Paul Makepeace wrote:
> On Wed, Jan 15, 2003 at 04:30:44PM -0800, Belden Lyman wrote:
>
>>Flush pipes, print $|:
>>
>> % perl -MData::Dumper -e '$|++; print Dumper \$|'
>> $VAR1 = \'1';
>>
>>Okay, I believe that.
>>
>>Clog pipes, print $|:
>>
>> % perl -MData::Dumper -e '$|--; print Dumper \$|'
>> $VAR1 = \'1';
>>
>>Huh? Same value? That can't be right though, because
>
>
> This is a known perl oddity, and often used by golfers and obfuscators
> as a toggler.
>
> $ perl -le 'print "p",--$|,"ng!" for 1..4'
> p1ng!
> p0ng!
> p1ng!
> p0ng!
> $
>
> Paul
>
Sure, I know that. :)
My intended question was, "How come Data::Dumper thinks $|-- has the
same value as $|++ ?"
Your example is better at showing that $| obviously is changing value.
But it doesn't explain why printing $| using Data::Dumper always gives
back \'1', seemingly without regard to the actual value of $| at the
time.
I suspect the problem is that within the context of Data::Dumper, $|
is always flushed, but I'm grasping here.
Belden
More information about the Oakland
mailing list