Thanks Thomas. > -----Original Message----- > From: Thomas Bätzler [mailto:[EMAIL PROTECTED] > Sent: 09 June 2005 09:50 AM > To: 'Perl Beginners' > Cc: Tielman Koekemoer (TNE) > Subject: RE: Read output from script line by line > > Tielman Koekemoer (TNE) <[EMAIL PROTECTED]> asked: > > Is there a way you read input from a script line by line. > I'd rather > > parse output line by line than do: @out = `script.sh`; which seems
> > sloppy. Or is that the best way? > > No, not really. > > You can do a "pipe open" like this > > my $code = '/path/to/your/script'; > my @args = qw( -x -y -z ); > > open( IN, '-|', $code, @args ) or die "Can't spawn '$code': $!"; > > and then leisurely read your input: > > while( my $line = <IN> ){ > # do something > } > > In any case, I recommend that you read the perlopentut and > perlipc manpages for thw whole story ;-) > > HTH, > Thomas > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>