B
Bob
$|++;
I see that in code but my searches have come up with nothing.
Robert
I see that in code but my searches have come up with nothing.
Robert
As $| is a boolean variable, I suspect the one who wrote this thoughtI see that in code but my searches have come up with nothing.
Bob said:$|++;
I see that in code but my searches have come up with nothing.
$|++;
I see that in code but my searches have come up with nothing.
Bob said:$|++;
I see that in code but my searches have come up with nothing.
$| is explained in
perldoc perlvar
the ++ is just a cute way to set it to a true value. if assumes
the value is not -1
gnari
Abigail said:There's no advantage of writing '$| ++' instead of '$| = 1', but
the latter is far less obscure.
And the latter turns on buffering also in the extremely unlikely
event that $| should ever be -1, in which case $|++ would turn it
off.
And the latter turns on buffering also in the extremely unlikely
event that $| should ever be -1, in which case $|++ would turn it
off.
Jeff 'japhy' Pinyan said:$|, as defined by the internal magic supporting it, is set to 0 when given
a false value, and 1 when given ANY true value.
gnari said:on the other hand $|-- will always reverse the value.
now I will have to find a use for that ...
Jeff 'japhy' Pinyan said:Except that $| can't ever be -1 (unless you've done *| = \-1, in
which case $|++ will throw a "Modification of read-only" error).
in that case the $|++ does not even have the advantage
of allowing us to 'localize' the value as in:
# unknown $| state
$|++;
... do stuff ...
$|--;
this will alway end by resetting $| to 0, even if it
was originally 1
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.