But those are really esoteric cases; and if you're really panicky, just say $| = 0 or $| = 1.tie $|, 'Pkg', ...; # or *| = *foo; $foo = 100; print $|; # 100!
For those interested, $| is as good as a boolean:
Perl_magic_get() ends up returning a 0 or a 1 (which is what you get when you fetch the value of $|). Perl_magic_set() determines whether the value you're setting $| to is true or false, and sets or unsets the IOf_FLUSH bit accordingly./* in sv.h */ #define IOf_FLUSH 4 /* in mg.c -- the magic file */ /* in Perl_magic_get() */ case '|': sv_setiv(sv, (IV)(IoFLAGS(GvIOp(PL_defoutgv)) & IOf_FLUSH) != 0 ); break; /* in Perl_magic_set() */ case '|': { IO *io = GvIOp(PL_defoutgv); if ((SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv)) == 0) IoFLAGS(io) &= ~IOf_FLUSH; else { if (!(IoFLAGS(io) & IOf_FLUSH)) { PerlIO *ofp = IoOFP(io); if (ofp) (void)PerlIO_flush(ofp); IoFLAGS(io) |= IOf_FLUSH; } } } break;
In reply to Re: $ = 0 at start of script
by japhy
in thread $|= 0 at start of script
by pileswasp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |