hi all

thanks for the help!! i am  hoping to use the chmod thing
or the one from zentara.

thanks again
Saurabh

On 1/8/06, zentara <[EMAIL PROTECTED]> wrote:
>
> On Sat, 7 Jan 2006 11:09:25 +0000, [EMAIL PROTECTED] (Saurabh
> Singhvi) wrote:
>
> >hi people
> >
> >i have a script that executes external binaries using the system command.
> >now the problem is this:
> >
> >the external binary is HUGE in terms of ram usage so i need a way to keep
> it
> >loaded in the memory
> >so that i can keep passing the next parameters, instead of loading it
> each
> >time.
> >
> >kindly guide me about this
>
> Assuming you are talking about a single script execution:
>
> If you only need to feed it on STDIN and not collect output, you can use
> the piped form of open.
> ######################################################
> open( FH, " | my_huge_program") or warn "$!\n";
>
> print FH "data1";
> #wait
> print FH "data2";
>
> # etc etc etc
> close FH;  #will remove it from memory
> ########################################################
>
> If you need to collect the STDOUT and STDERR too, you
> can open it with IPC::Open3, feed it's STDIN and collect
> it's STDOUT and STDERR
>
> ######################################################
>
> use warnings;
> use strict;
> use IPC::Open3;
> use IO::Select;
>
> #interface to "bc" calculator
> my $pid = open3(\*WRITE, \*READ,\*ERROR,"bc");
>
> my $sel = new IO::Select();
>
> $sel->add(\*READ);
> $sel->add(\*ERROR);
>
> my($error,$answer)=('','');
>
> while(1){
>
> print "Enter expression for bc, i.e. 2 + 2\n";
> chomp(my $query = <STDIN>);
>
> #send query to bc
> print WRITE "$query\n";
>
> foreach my $h ($sel->can_read)
> {
>    my $buf = '';
>    if ($h eq \*ERROR)
>    {
>      sysread(ERROR,$buf,4096);
>      if($buf){print "ERROR-> $buf\n"}
>    }
>    else
>    {
>      sysread(READ,$buf,4096);
>      if($buf){print "$query = $buf\n"}
>    }
> }
> }
>
> waitpid($pid, 1);
> # It is important to waitpid on your child process,
> # otherwise zombies could be created.
> __END__
>
>
>
>
>
>
>
> --
> I'm not really a human, but I play one on earth.
> http://zentara.net/japh.html
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>

Reply via email to