http://www.perlmonks.org?node_id=633780


in reply to Backticks and SIGALRM

You might try qx instead of backticks.
#!/usr/bin/perl # qx does interpolation too # generalized form for using backticks $output=qx(ls -la); print "$output\n"; $output = `ls`; print "$output\n";

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: Backticks and SIGALRM
by halley (Prior) on Aug 20, 2007 at 16:12 UTC
    It is useful to remember that qx// is backticks. It's just another syntax to get there. It doesn't exercise any different code path, it won't behave any different, except how the parser finds the end of the string (you could type qx/foo `blah`/ without needing special escape characters to get the backquotes into the shell).

    Also, q// is single-quoted, and qq// is double-quoted. Same thing.

    --
    [ e d @ h a l l e y . c c ]

Re^2: Backticks and SIGALRM
by nemo (Sexton) on Aug 20, 2007 at 12:53 UTC
    Thank you for your replies.
    I attempted the solution using qx but I had the same result. Executing the command using the shell seems to be the problem, the sigalrm is not delivered. It's an interesting problem I haven't come across before.
    I was considering using system to redirect the output of the command to a temporary text file and then reading the tmp file to parse output one line at a time.
    I should also mention I am working on Win32 Boo! ;)

    Nemo
Re^2: Backticks and SIGALRM
by ikegami (Patriarch) on Aug 21, 2007 at 14:53 UTC
    qx and `` produce the same code.