in reply to Formatting Long String in Backticks

Your 1st code will execute a single external command, but your 2nd will execute two external commands.

I bet you really want something like this:

my $cmd = qq! testing testing ! . qq! ... testing testing !; my $test = qx! $cmd !;

Replies are listed 'Best First'.
Re^2: Formatting Long String in Backticks
by Anonymous Monk on Mar 09, 2010 at 23:52 UTC
    I am trying to avoid to do what you just did. If this can be written elegantly like this.
    my $cmd = qq! testing testing ! . qq! ... testing testing !;
    then why can't this code be re-written elegantly as well?
    my $test = qx! testing testing ! . qx! ... testing !;
    There must be a way to write the qx where I do not need to use $cmd anymore.
      then why can't this code be re-written elegantly as well?
      Because the dot (.) is defined as catenating strings. Hence,

      qx(a).qx(b)
      is valid, but is defined as catenating the result of qx(a) and the result of qx(b), which is of course different from qx(a b).

      -- 
      Ronald Fischer <ynnor@mm.st>

      Stupid Array Interpolation Trick #158:

      >perl -wMstrict -le "my $test = qx{ @{[ qw(echo testing ...)[0, 1, 1, 1, 2, 1] ]} }; print qq{'$test'}; " 'testing testing testing ... testing '