in reply to Get output after running IPC::Run

Re update 2,

chomp returns what it chomped, if anything. Since the string doesn't end with a newline (the content of $/), chomp returns an empty string or something equally false.

So adjust $/ if you want to chomp something other than newlines. But even then, it makes no sense to check what chomp returns. Use

chomp($out), print "Output: $out\n" if $out;
or the saner
if ($out) { chomp($out); print "Output: $out\n"; }

Actually, why is the chomp conditional?

chomp($out); print "Output: ", length($out) ? $out : "[nothing]", "\n";

Replies are listed 'Best First'.
Re^2: Get output after running IPC::Run
by pid (Monk) on Nov 24, 2009 at 07:07 UTC

    Hi,

    In the wrong previous revision of my code, ``&&'' is used mistakenly. Its actual meaning is ``,''.
    Realized what's wrong, I fixed my code. Also, thanks very much for the third one, it's much better.

    Thanks again.