Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Preprocessing print statements

by LanX (Saint)
on Nov 11, 2020 at 12:19 UTC ( [id://11123584]=note: print w/replies, xml ) Need Help??


in reply to Preprocessing print statements

two alternative approaches:

a) If you are OK with buffering, you can still use select with a filehandle opened to a \$scalar and filter the scalar before printing. This has the advantage of minimal changes.

b) Personally I'd prefer my own out() routine - closing over a regex var - to replace all needed prints. That'll give you finer control over the single print chunks.

HTH

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

UPDATED: Clarified that these are two different approaches.

Replies are listed 'Best First'.
Re^2: Preprocessing print statements
by mauroid (Initiate) on Nov 11, 2020 at 13:42 UTC

    Thank you. Could you please provide a sample code snippet? I am not entirely clear how to do what you suggest.

        "... straight forward..."

        The classic 24/7 support talk.

        Phone call round midnight:

        Customer: "I got this nose/cuke problem." Support: "Replace nose with cuke. Customer: "But i don't understand!" Support: "The solution is obvious. Good night."

        Situation in the morning AKA aftermath:

        [] All servers shutdown [] All airplanes grounded [] Perlmonks offline [] No transactions today [] All centrifuges bursted [] Don T. stays in office

        Whatever could happen. But then you are fired.

        «The Crux of the Biscuit is the Apostrophe»

        perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found