On Fri, 2002-06-14 at 07:15, Franck FASANO wrote:
> >
> > Objet: Re: How to open STDOUT ?
> > Date: Thu, 13 Jun 2002 21:34:16 -0700
> > De: "Todd Wade" <[EMAIL PROTECTED]>
> > A: [EMAIL PROTECTED]
> >
> > "Franck Fasano" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Hi,
> > >
> > > I have recuperated a module from the web and I interfaced
> > > with it but STDOUT is closed .
> > > If I do a : print STDOUT "hello\n" in my script, nothing appeared .
> > >
> > > I don't know where STDOUT is closed and how to re-open it ?
> > >
> >
> > I would try to figure out why its closed first.
> >
> > say:
> >
> > print STDOUT "hello\n" or die("Print failed: $!");
> >
> > this will call die() if print() returns false, reporting the error.
> >
> > Todd W
> >
> 
> There is no error reporting by print but I succeed to find in what
> case it doen't work :
> 
> Let's see the 2 scripts test.pl and test2.pl  :
> 
> If you execute "test.pl" it works and print correctly.
> 
> If you execute "test2.pl" which executes test.pl, it doesn't work .
> 
> Why? I don't know ? ...
> ----
> 
Because STDOUT is redirected to your application.  You want the system
function.  The test2.pl script should read

#!/usr/local/bin/perl -w

use strict;
#use warnings; #what do you think the -w does? remove one or the other

my $ret_code =  system('./test.pl -P @ARGV');


or you want to use the qx`` operator the way it is supposed to be used

#!/usr/local/bin/perl -w

use strict;
#use warnings; #what do you think the -w does? remove one or the other

foreach my $line (qx{ ./test.pl -P @ARGV}) {
        #possibly meddle with $line
        print $line;
}

-- 
Today is Setting Orange the 19th day of Confusion in the YOLD 3168
Hail Eris, Hack Linux!

Missile Address: 33:48:3.521N  84:23:34.786W


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to