[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TMTOWTDI



--- Vicki Brown <vlb@cfcl.com> wrote:
> # Which way would you pick?  Why
> 
> # Problem
> # You have an external command to run from perl; the command returns
> a
> # large chunk of newline separated data which you want to process,
> line
> # per line.
> #
> #    1) write the returned data to a file, open it, and loop through
> the lines
> #

I've had occasion to choose this because I wanted to catch STDIN and
STERR from an old script seperately:

system("./stage1.pl $ffile 1> $s1out 2> $s1err" );
open(OUT,"<$s1out") || return "Cannot open $s1out:\n $!\n";
open(ERR,"<$s1err") || return "Cannot open $s1err:\n $!\n";

Mind you, the old script had been an old hatchet job that would be
really hard to retrofit to a more convenient method.

I know that the system call could be constructed a little safer, and
all of this I got from the wonderful _Perl Cookbook_. All in all, it's
ugly, slow, and it works.

Anyone who knows a better (funner) way, please spread the word.


===
Be seeing you.
-----------------------------------------------------------
B. Law (ofermod@yahoo.com)
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org