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.


In reply to Re^2: Is it possible to include colored text in formatted output using write by fireblood
in thread Is it possible to include colored text in formatted output using write by fireblood

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.