Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 avoiding work at the Monastery: (3)
As of 2026-02-14 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.