For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > March 2005 > Understanding - qx









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Understanding - qx
codefixer@gmail.com

2005-03-31, 3:58 am

Hi,

I have the following line in my script test.pl running on Red Hat
Linux.

my $result = qx/g++ -Wno-deprecated test.cpp/;

If test.cpp fails to compile, then all the errors messages are shown on
screen.

The same script when run on Windows and replacing the compiler by "cl"
nothing spits on screen and everything is returned in $result.

Any idea for the occurance of this discrepancy ?

Thanks.

John Bokma

2005-03-31, 3:58 am

wrote:

> Hi,
>
> I have the following line in my script test.pl running on Red Hat
> Linux.
>
> my $result = qx/g++ -Wno-deprecated test.cpp/;
>
> If test.cpp fails to compile, then all the errors messages are shown on
> screen.
>
> The same script when run on Windows and replacing the compiler by "cl"
> nothing spits on screen and everything is returned in $result.
>
> Any idea for the occurance of this discrepancy ?


cl outputs to stdout I guess, and g++ to stderr. Redirect stderr to stdout
when you use g++.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

Joe Smith

2005-03-31, 8:56 am

codefixer@gmail.com wrote:

> I have the following line in my script test.pl running on Red Hat
> Linux.
>
> Windows: nothing spits on screen and everything is returned in $result.
>
> Any idea for the occurance of this discrepancy ?


There's an FAQ on this subject, the key word is "STDERR".
perldoc -q STDERR
Pay attention to all the examples using `2>`.

-Joe
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com