Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Is it possible to include colored text in formatted output using write

by fireblood (Scribe)
on May 11, 2023 at 22:56 UTC ( [id://11152111]=note: print w/replies, xml ) Need Help??


in reply to Re: Is it possible to include colored text in formatted output using write
in thread Is it possible to include colored text in formatted output using write

Here is what I currently have. I'm defining the format in an eval instruction because later I plan to set the length of the field based on the width of the screen window, but at present it is as follows:

my $format_definition_expression = "format one_field_format =\n" . "@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" . "\$one_field_text\n" . ".\n"; eval $format_definition_expression;

Later on down I have:

unless (open ($fh_more_pipe, "|-", "cat - | more")) { print "\nCould not open \$fh_more_pipe: $!\n\n"; die; } select $fh_more_pipe; $|++; $~ = "one_field_format"; my $one_field_text = "The purpose of the " . colored ($StdHdr::ThisScriptName, "green") . " script is to search for a specified character string " . "in all plain text files that reside in and below a " . "specified starting directory, optionally writing " . "the names of matching files to a specified save file." . "n\n"; write;

I know that I will need to add double-tildes (~~) to the line in the format definition to make the text that I want to display to flow to as many subsequent lines as necessary to accommodate the entire text of the message, but for now I'm just focusing on getting the colored text elements to be properly rendered in just the first line before going on to that.

Thanks for looking at this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11152111]
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 01:52 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.