in reply to Using backquotes to echo results in "Bad file descriptor"

Although this is not cause of the "Bad File Descriptor" message, a small observation about your sample code: it is a good idea to get in the practice of assigning things like $! (os error), $? (child error) and $@ (thrown exception) $^E (extended OS error) and so on to a variable immediately after the call that generates them. If you are not watchful, the code to process them can accidentally reset them.

The practice of assigning them straight away to a named variable prevents this and many a wild goose chase looking for bugs.

Best, beth

Replies are listed 'Best First'.
Re^2: Using backquotes to echo results in "Bad file descriptor"
by dwm042 (Priest) on Mar 04, 2009 at 18:57 UTC
Re^2: Using backquotes to echo results in "Bad file descriptor"
by motionblurrr (Initiate) on Mar 04, 2009 at 19:11 UTC
    As in like this?:
    #!/usr/bin/perl $res = `echo test`; print $! . "\n";' print $res;
    Good point, thanks.