G'day tarunmudgal4u,

Without knowing exactly how the data is generated, it's a little difficult to give a clear answer on how to format it. While you do say there's message/status pairs, that doesn't address 'Mapped to V drive' (line 2) which doesn't have a status nor the source or importance of the blank lines you show.

In the code below, I've put the data you've posted into an Array of Arrays and processed that. You should be able to adapt the technique I've used for your needs.

#!/usr/bin/env perl use strict; use warnings; my @messages = ( ['Mapping a drive to build machine 10.211.32.254..', 'done'], ['Mapped to V drive'], [], ['Deleting TestHarness_LUA directory..', 'done'], [], ['Deleting TestHarness_LUA-distribution.zip file..', 'done'], [], ['Copying TestHarness_LUA-distribution.zip from mapped V drive..', + 'done'], ); for my $msg (@messages) { for (scalar @$msg) { $_ == 0 && do { print "\n"; last }; $_ == 1 && do { print_long_line($msg->[0]); print "\n"; last } +; $_ == 2 && do { print_long_line($msg->[0]); print "$msg->[1]\n +" }; } } sub print_long_line { print join "\n" => map { sprintf "%-55s" => $_ } shift =~ /(.{1,52 +})\b\s*/g; }

Output:

$ pm_format_long_line_output.pl Mapping a drive to build machine 10.211.32.254 done Mapped to V drive Deleting TestHarness_LUA directory done Deleting TestHarness_LUA-distribution.zip file done Copying TestHarness_LUA-distribution.zip from mapped V drive done

-- Ken


In reply to Re: Console Output Formatting Help Required by kcott
in thread Console Output Formatting Help Required by tarunmudgal4u

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.