in reply to Formatting Long String in Backticks
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
|
|---|