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> };