If you don't need interpolation, put your long command string into an array instead using the quote-words (qw{ ... } in Quote Like Operators) operator which allows you to break the word list over multiple lines.

knoppix@Microknoppix:~$ perl -E ' > @cmd = qw{ > ps > -ef > | > grep > gnome > | > grep > -v > grep > }; > $res = qx{ @cmd }; > print $res;' knoppix 3829 1 0 09:40 ? 00:00:01 gnome-terminal knoppix 3834 3829 0 09:41 ? 00:00:00 gnome-pty-helper knoppix 3856 1 0 09:41 ? 00:00:30 gnome-terminal knoppix 3858 3856 0 09:41 ? 00:00:00 gnome-pty-helper knoppix 4006 4005 0 09:43 ? 00:00:00 gnome-pty-helper knoppix@Microknoppix:~$

Even if you do need interpolation you can use this method by using push and breaking your word list up a bit so that interpolated variables go in the gaps.

knoppix@Microknoppix:~$ perl -E ' > $lookFor = q{gnome}; > push @cmd, > qw{ > ps > -ef > | > grep > }, > $lookFor, > qw{ > | > grep > -v > grep > }; > $res = qx{ @cmd }; > print $res;' knoppix 3829 1 0 09:40 ? 00:00:02 gnome-terminal knoppix 3834 3829 0 09:41 ? 00:00:00 gnome-pty-helper knoppix 3856 1 0 09:41 ? 00:00:30 gnome-terminal knoppix 3858 3856 0 09:41 ? 00:00:00 gnome-pty-helper knoppix 4006 4005 0 09:43 ? 00:00:00 gnome-pty-helper knoppix@Microknoppix:~$

I hope this is of use.

Cheers,

JohnGG


In reply to Re: Formatting Long String in Backticks by johngg
in thread Formatting Long String in Backticks by Anonymous Monk

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.