in reply to Line breaks within backticks

This solution allows indentation and "syntactically" is still one statement

lhp@nereida:~/Lperl/src/testing$ cat -n qx.pl 1 print ( 2 $c = 'ls -l '. 3 join(' ', qw{ 4 context1.pl 5 decomposed_char_utf8_2.pl 6 file1.txt 7 es.log} 8 ) 9 and qx{$c} 10 );

substitute join ' ' by join '' to assume the restriction that spaces aren't allowed between args.

Casiano

Replies are listed 'Best First'.
Re^2: Line breaks within backticks
by ikegami (Patriarch) on May 08, 2008 at 12:29 UTC

    Better yet, use the multiple argument form to avoid (lack of) escaping problems and to simplify the code.

    my @cmd = ( 'ls', '-l', 'file1', 'file2', 'file with space', ); my $results = do { open(my $fh, '-|', @cmd) or die("Unable to run $cmd[0]: $!\n"); local $/; <$fh> };

    PS - Why did you use and there instead of making two statements?!

    Update: Fixed wrong variable name.

Re^2: Line breaks within backticks
by BjornStenborg (Initiate) on May 08, 2008 at 12:41 UTC
    Nice solution, but it turns into even more code, which kind of negates the point. :)