in reply to Re^4: Using backquotes to echo results in "Bad file descriptor"
in thread Using backquotes to echo results in "Bad file descriptor"

Not entirely sure, but an interesting test case I found is the following:

perl -e 'print `echo test`; print $!."\n";'

shows $! to be empty. I am guessing the issue is that echo is attempting to output to a non-existent terminal, and this error is a result of an internal perl call to determine if the output is being piped to an existing terminal. Note that

perl -e 'print $res = `echo test`; print $!."\n";'

does yield $! eq "Bad file descriptor".

Replies are listed 'Best First'.
Re^6: Using backquotes to echo results in "Bad file descriptor"
by motionblurrr (Initiate) on Mar 04, 2009 at 21:31 UTC
    So... when perl is outputing the data using print, it doesn't cause the error, but when it's sending it to a scalar, it isn't really a terminal, so it causes $! to have that error. I can go with that. Makes a lot of sense actually. Thank you!