6.1 years ago by
EMBL Heidelberg, Germany
I tend to check availability of an external program with
$path_to_blastn = qx(which blastn);
unless ($path_to_blastn) { die "\nERROR: blastn not found"; }
I think Siva's suggestion should be (note the &
after 2)
blastn -h 2&>error.txt
The problem I have with it is that you then have to parse the file and decide whether what's inside is an error message and whether it indicates that the program is not installed. Also relying on shell redirection is less portable than relying on which
(for example I think 2&>
doesn't work with tcsh).
As an alternative you can also use system
:
system("blastn -h ") == 0 or die ...
but then you need to process the returned error code yourself.
Finally, if you still want to go with open, check IPC::Open2
and IPC::Open3
. Open3
is, I believe, the only way of getting STDERR without involving the shell.