in reply to Line breaks within backticks

I would use your first method, but if you must do it in one statement you can try
use strict; use warnings; my $result = qx[${\ ( 'ls -l ' . '/etc' . '/passwd' ) }]; print $result . "\n";
output:
-rw-r--r-- 1 root root 1867 Apr 28 15:00 /etc/passwd
Update see also Perl Idioms Explained - ${\$obj->method} and @{[sort @list]}

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

    Excellent! Thank you. I tried similar constructs, but didn't find the "${\(...)}" combination. So what we're doing is creating a reference and then dereferencing it, right? It seems a bit backward, but... if it works, it works.

    And I agree, the two-step solution is probably prettier, but I'm trying to write compact code for a coding contest, so fewer lines is more important in this case.