Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Race when redirecting output.

by ikegami (Patriarch)
on May 22, 2025 at 19:02 UTC ( [id://11165082]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Race when redirecting output.
in thread Race when redirecting output.

It doesn't need to be an open handle. You can use tie *FH, ... out of the blue. You can use tie local *FH, ... for something localized.

$ perl -e' use v5.40; use feature qw( bareword_filehandles ); use Tie::Simple qw( ); tie *FH, Tie::Simple::, undef, PRINT => sub { shift; my $msg = join( defined( $, ) ? $, : "", @_ ); $msg .= $\ if defined( $\ ); say STDOUT "[$msg]"; }; say FH "Hello!"; ' [Hello! ]

Without bare word file handles:

$ perl -e' use v5.40; use Symbol qw( gensym ); use Tie::Simple qw( ); my $fh = gensym; tie *$fh, Tie::Simple::, undef, PRINT => sub { shift; my $msg = join( defined( $, ) ? $, : "", @_ ); $msg .= $\ if defined( $\ ); say STDOUT "[$msg]"; }; say $fh "Hello!"; ' [Hello! ]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11165082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2025-07-18 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.