----- Original Message -----
From: "Harry Putnam" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 30, 2003 4:52 PM
Subject: Re: make CPAN::Shell->i; print to a filehandle
> [EMAIL PROTECTED] writes:
>
> > There is no point of arguing over this { After all this is a
> > friendly group },but I think thats where you had a misunderstanding
> > of your formulation in the first place. The problem as translated {
> > by final result } was how can I redirect the output of a runing
> > process.
>
> Yup, nuf said on that front. You've been very patient.
> And its nearly always true that my programming suffers from confusion
> all along the way.
>
> What do you think of this method?... It's snipped down quite a lot
> but you can still see the idea.
Ok I am diving in.
>
> I tried to explain what I think is happening in my comments but not
> sure I really got it right.
thats ok, I always try to get it down on paper first though. Need a flow
chart other wise things always get messY.
> A whole series of other getops choices
> are snipped for clarity:
>
> #!/usr/local/bin/perl -w
>
> # [...]
> # [snipped gobs of tests and file checks]
> # [...]
> use CPAN;
> use vars qw($opt_r $opt_i $opt_m $opt_b $opt_d $opt_a);
> use Getopt::Std;
> my $optstr ="ra:b:d:i:m:";
> getopts($optstr);
>
> ## Build or refresh the local database
> if($opt_r){
> if($ARGV[0]){
> usage();
> print "No arguments allowed with -r flag\n";
> exit;
> }
> # Start another instance of this script (Fork)
> # and connect the standard output of the child process to the file
> # handle specified. See the entry for the open() function in perlfunc, and
> # perlipc for plenty of info.
> my $pid = open(CPAN_I, "-|");
> die "Cannot fork: $!" if not defined $pid;
>
> ## If the fork worked... run our data collector.
> if ($pid == 0){ # child
> CPAN::Shell->i;
> exit 0;
> }
>
> ## While its running print it to disk
> open(FH,">$target")or die "Cannot open $target: $!";
> print "\n Refreshing/Creating $target...\n";
> while(<CPAN_I>){
> print FH $_;
> }
> close(FH);
> ## Shut down the fork.
> close CPAN_I or warn "child exited: $?";
> }
>
> # [...]
>
> sub usage {
> print<<EOM;
>
> Purpose: Search an on disk copy of cpan holdings
> (listed by Author Module Distribution and Bundle)
> Usage: \`$myscript [-r <no args>] -[abdmi] \"REGEX\"'
> Flags: -a search Author section for REGEX
> -b search Bundle section for REGEX
> -d " ditto " Distribution section
> -m " ditto " Module section
> -i All of above
> Special:
> -r can only be used by itself and is used to refresh or
> create the on disk copy of cpan information.
> (Defaults to /usr/local/cpan/cpan_dat/combo_list.dat)
> NOTES:
> Consider that with -[abdmi] flags the supplied REGEX will be
> inserted after some default settings I.E.:
> ^DEFAULT_STRING +REGEX
> So to look for somethiong deeper in a line .. use:
> \`$myscript -[abdmi] ".*REGEX" '
>
> EOM
> }
>
Cool, that should work. You will loose some noticable time if you are going
to install 10 or so modules. This is primary due to: spawning on each child
and reastablishing TCP connection. But it does the job :O)
Mark G.
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]