[JaxPM] autoflush

Greg Sabino Mullane greg at turnstep.com
Sun Dec 30 12:13:26 CST 2001


On the jacksonville-pm-list; Jax.PM'er "Greg Sabino Mullane" <greg at turnstep.com> wrote -


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> I've been getting weird results with trying to turn on 
> autoflushing for filehandles. Can I just set "$| = 1;" once at 
> the top of the script to affect all filehandles or do I have 
> to "select" a filehandle then set the "$|" variable?

You have to set it for each one: $| only affects the currently 
selected filehandle. One easy way to do this is like this:

select((select(FOO),$|=1)[0]);

which temporarily selects the filehandle "FOO", sets autoflushing 
on, and then selects back into the previous filehandle. I use 
this a lot. Someday perl will have an "autoflush by default" 
which would be really, really nice. It's the default in 
IO::Handle module, but not when doing it yourself.

All of this is covered in perlfaq5, first question, by the way. 
Try 'perldoc -q flush' to jump to it from a command prompt.

Greg Sabino Mullane
greg at turnstep.com
PGP Key: 0x14964AC8 200112301301

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBPC9YZ7ybkGcUlkrIEQLs3QCg5xH4/ROOtWxnnPeSoHhF4qz+m0wAoJLj
579rjLwYlQ7hNQnTsS4imjGE
=dtfL
-----END PGP SIGNATURE-----



Jax.PM Moderator's Note:
This message was posted to the Jacksonville Perl Monger's Group listserv.
The group manager can be reached at -- owner-jacksonville-pm-list at pm.org
to whom send all praises, complaints, or comments...




More information about the Jacksonville-pm mailing list