This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.mel.connect.com.au!newshub1.rdc1.nsw.optushome.com.au!news1.belrs1.nsw.optushome.com.au.POSTED!not-for-mail
From: elephant@squirrelgroup.com (jason)
Newsgroups: comp.lang.perl.misc
Subject: Re: Why $|++ instead of $|=1 ?
Message-ID: <MPG.13d91d359d08eb9298969f@news>
References: <8k0m4d$13o$1@panix3.panix.com> <slrn8m7qfq.8d6.tjla@thislove.dyndns.org> <fbS85.9$E27.2912@vic.nntp.telstra.net> <8kknbg$c2e$1@pegasus.csx.cam.ac.uk> <slrn8mssqj.19b.tjla@thislove.dyndns.org> <MPG.13d913ce7cbe40b98969e@news> <HNub5.6$oA.3943@vic.nntp.telstra.net>
Organization: squirrel web
X-Newsreader: MicroPlanet Gravity v2.11
Lines: 60
Date: Fri, 14 Jul 2000 02:50:11 GMT
NNTP-Posting-Host: 203.164.14.239
X-Complaints-To: abuse@optushome.com.au
X-Trace: news1.belrs1.nsw.optushome.com.au 963543011 203.164.14.239 (Fri, 14 Jul 2000 12:50:11 EST)
NNTP-Posting-Date: Fri, 14 Jul 2000 12:50:11 EST
Xref: nntp.stanford.edu comp.lang.perl.misc:325864
Wyzelli wrote ..
>jason <elephant@squirrelgroup.com> wrote in message
>news:MPG.13d913ce7cbe40b98969e@news...
>>
>> while I'm still against it's use from a clarity standpoint - it's
>> magic means that there's no way that $|++ will result in anything
>> other than $| == 1 .. therefore
>>
>> {
>> local $|;
>> $|++;
>> }
>>
>> is always going to work as desired .. I'd prefer to do it in one clear
>> line though with a
>>
>> local $| = 1;
>>
>
>I think the point we are making is that $|-- does NOT always set to 0
>which is the dangerous half of the equation.
I think that point is well made .. although I'm half expecting someone
to propose using $|-- all the time for toggling buffering on and off
to be honest - in all the code examples where I've seen $|++ I've never
seen $|--
one should remember that $| only affects the buffering of the currently
selected filehandle - so it's effectively localised by a new select() ..
eg.
# code begins
open FOO, ">bar";
select FOO;
$|++;
print STDOUT "\$| with FOO selected: [$|]\n";
select STDOUT;
print "\$| with STDOUT selected: [$|]\n";
select FOO;
print STDOUT "\$| with FOO selected: [$|]\n";
# code ends
the majority of examples that I've seen using $|++ involve the following
familiar construct
select( (select(FOO), $|++)[0]);
my point is simply that it's probably not as critical as the volume of
discussion it's receiving here would imply .. but I still prefer the
$|=1 WTDI
--
jason -- elephant@squirrelgroup.com --