Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^12: Immediately writing the results of search-and-replace

by afoken (Chancellor)
on Aug 12, 2022 at 07:12 UTC ( [id://11146114]=note: print w/replies, xml ) Need Help??


in reply to Re^11: Immediately writing the results of search-and-replace
in thread Immediately writing the results of search-and-replace

my ($old, $new, $reset) = map "\e[${_}m", 91, 92, 0;

Left-hand side: Three variables, $old, $new, $reset.

Right-hand side: A map expression iterating over the three values 91, 92, and 0. map evaluates the expression "\e[${_}m" for each of the three values, resulting in the list "\e[91m", "\e[92m", "\e[0m".

Finally, the three element RHS list is assigned to the LHS list of variables.

The values are ANSI terminal escape sequences for setting text attributes, see https://en.wikipedia.org/wiki/ANSI_escape_code#SGR. 91 selects bright red foreground, 92 selects bright green foreground, 0 resets back to defaults.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-19 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found