Depending on the complexity of your output or the need for consistency over many scripts, you could use one of the templating modules or Perls internal formats. I've found Perls formats to pretty useful for short screen interaction. They give you a fair amount of control and good flexibility.

The problem with formats is that they tend to be specific to the program/script for the most part. I suppose you could share them in a module or package but I've never tried that. However, if the scripts you are converting are self contained, that may not be a limitation.

On the other hand, if you do have several scripts using screen outputs that are substantially the same, you might consider a templating module.

Here is an paired down example of a Perl format that I use now. Just to give you an idea of what it looks like.
sub GenerateRpt{ my $oldouthdl = select; $rtncd = 0; #initialize and gerate various variables here $Text::Wrap::columns = 40; select(STDOUT); # select(OUTFILE); to w +rite to a file $~ = "ERRRPT"; # $FORMAT_NAME $^ = "ERRRPT_TOP"; # $FORMAT_TOP_NAME $= = 81; # $FORMAT_LINES_PER_PAG +E $- = 0; # $FORMAT LINES_LEFT while(<INFILE>){ . # do somethings . . write; } # end while(<INFILE>) close(INFILE); select $oldouthdl; # restore original outp +ut file handle return $rtncd; #*****; format ERRRPT_TOP = @||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||| "$title01[$cat]" @||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||| "$title02" ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $cathdr[$cat] ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $cathdr[$cat] ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $cathdr[$cat] ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $cathdr[$cat] ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $cathdr[$cat] ---------------------------------------------------------------------- +----------- . format ERRRPT = Local Case Number: @<<<<<<<<<<<<<<<<<<< Seq: @<<< Crt: @< Ph +ase: @<<<<< $err[4], $err[5], $err[2], + $err[6] Err Number: @<<<<< Rec Number: @<<<<< Field Num +ber: @<<<<< $err[0], $err[1], $obfldnum +97{$err[8]} Field Information: Description: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $line01 ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $line01 ~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $line01 ---------------------------------------------------------------------- +----------- . } #end GenerateRpt()
Good Lucl PJ

PJ
use strict; use warnings; use diagnostics; (if needed)

In reply to Re: Text in Scripts by periapt
in thread Text in Scripts by monkmoose

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.