Re: piping the split.

2003-07-01 Thread Rob Dixon
Hi.

Vasudev.K. wrote:
> Hello,
>
> I want to unzip a file and run another perl script on it. So I tried to
> pipe the STDOUT to the script
>
>  -- system("gzip -d < abc.ndx | perl myscript.pl");
>
> but I suppose the STDOUT is huge so half way the system gives an
> error... "file too large" and exits.

By default gzip will decompress to the file named in the archive, not
to STDOUT. You need either

  gzip -cd abc.ndx
or
  zcat abc.ndx

>
> So I tried to split the STDOUT and run the perl script..
>
> -- system("gzip -d < abc.ndx | split -1000 | perl myscript.pl");
>
> But that doesn't solve the purpose as I need to run the script on each
> split.
>
> Can anybody suggest a better way of doing it?

I squirm a little every time I see backticks or calls to 'system'; partly
because the program becomes suddenly non-portable, but mainly because you
suddenly relinquish control over everything that is happening to a separate
utility while all your Perl program can do is to wait...

I would recommend using the Compress::Zlib library if you have it or can get
it installed. Depending on the functionality of your software it may also
be appropriate to do all the decompression within 'myscript.pl'.

HTH,

Rob




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



piping the split.

2003-07-01 Thread Vasudev.K.
Hello,

I want to unzip a file and run another perl script on it. So I tried to
pipe the STDOUT to the script

 -- system("gzip -d < abc.ndx | perl myscript.pl");

but I suppose the STDOUT is huge so half way the system gives an
error... "file too large" and exits.

So I tried to split the STDOUT and run the perl script.. 

-- system("gzip -d < abc.ndx | split -1000 | perl myscript.pl");

But that doesn't solve the purpose as I need to run the script on each
split.

Can anybody suggest a better way of doing it?

Thanks in advance














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