xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/lib/flush.pl (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#
2*0Sstevel@tonic-gate# This library is no longer being maintained, and is included for backward
3*0Sstevel@tonic-gate# compatibility with Perl 4 programs which may require it.
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# In particular, this should not be used as an example of modern Perl
6*0Sstevel@tonic-gate# programming techniques.
7*0Sstevel@tonic-gate#
8*0Sstevel@tonic-gate# Suggested alternative: IO::Handle
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate;# Usage: &flush(FILEHANDLE)
11*0Sstevel@tonic-gate;# flushes the named filehandle
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate;# Usage: &printflush(FILEHANDLE, "prompt: ")
14*0Sstevel@tonic-gate;# prints arguments and flushes filehandle
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gatesub flush {
17*0Sstevel@tonic-gate    local($old) = select(shift);
18*0Sstevel@tonic-gate    $| = 1;
19*0Sstevel@tonic-gate    print "";
20*0Sstevel@tonic-gate    $| = 0;
21*0Sstevel@tonic-gate    select($old);
22*0Sstevel@tonic-gate}
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gatesub printflush {
25*0Sstevel@tonic-gate    local($old) = select(shift);
26*0Sstevel@tonic-gate    $| = 1;
27*0Sstevel@tonic-gate    print @_;
28*0Sstevel@tonic-gate    $| = 0;
29*0Sstevel@tonic-gate    select($old);
30*0Sstevel@tonic-gate}
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate1;
33