문제

so I call an external program in perl and want to capture it's output:

my @RNAalifoldOut = `RNAalifold some parameters`;

If called from command line the output consists of three lines, e.g:

4 sequences; length of alignment 48.
__GCCGA_UGUAGCUCAGUUGGG_AGAGCGCCAGACUGAAAAUCAGA 
...((((.....((((.........)))).(((((.......)))))

However my array @RNAalifoldOut contains only the two last lines and the first line appears directly on the screen when the line is being executed.

How can this be? I thought maybe the program writes the first line to STDERR, but isn't that discarded by the backticks operator? And what could I do to hide this output?

Regards Nick

도움이 되었습니까?

해결책

You are likely seeing the standard error from RNAalifold. Backticks capture only the standard output.

Capture both standard output and standard error by changing your code to

my @RNAalifoldOut = `RNAalifold some parameters 2>&1`;

To discard the standard error, use

my @RNAalifoldOut = `RNAalifold some parameters 2>/dev/null`;

on Unix-like platforms. On Windows, use

my @RNAalifoldOut = `RNAalifold some parameters 2>nul`;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top