[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.

I tried to explain what I think is happening in my comments but not
sure I really got it right.  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
}




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

Reply via email to