You have to read all the way to the last paragraph of perlform

Within strings that are to be displayed in a fixed length text field, each control character is substituted by a space. (But remember the special meaning of "\r" when using fill mode.) This is done to avoid misalignment when control characters "disappear" on some output media.

It works just fine with a variable length field, but that's probably not very useful for you...

#!/usr/bin/perl use strict; use warnings; my $Status="\033[32mSTATUS\033[0m"; my $ms = 6; my $count = 42; format STDOUT = ^<<<<< ^<<<<< @* $ms, $count, $Status . write STDOUT;

My advice: If you are dealing with a single line format, just use sprintf instead.

UPDATE: Actualy your "data" probably doesn't have control characters in it right? you're just trying to shove control characters into it -- what you relaly want is for your format to have control characters in it. While that's not possible, you can use variable width fields that you know will always get filled with 0 length values (which just happen to be control characters...

#!/usr/bin/perl use strict; use warnings; my $Status="STATUS"; my $ms = 6; my $count = 42; my $START_COLOR = "\033[32m"; my $CHANGE_COLOR = "\033[36m"; my $END_COLOR = "\033[0m"; format STDOUT = ^<<<<< @* ^<<<<<< @* ^<<<<<<<<<<<<< @* $ms, $START_COLOR, $count, $CHANGE_COLOR, $Status, $END_COLOR . write STDOUT;

In reply to Re: Escape characters with FORMAT? by hossman
in thread Escape characters with FORMAT? by dayton

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.