Brian Volk wrote:
> Hi All,
> 
> I have a directory full of .txt files that I need to send to
> Regexp::Common...  I want to over ride the diamond operator by
> defining the directory using @ARGV .  I'm not sure how I define
> it......  Please help, w/o too much laughing! :-)
> 
> -------------------------  the start
> --------------------------------------------
> #!/usr/bin/perl -w
> 
> use Regexp::Common qw /URI/;
> 
> $dir = "/Program Files/OptiPerl/test_files";
>        opendir (BIN, $dir) or die "Can't open $dir: $!";
>        while ( defined ($file = readdir BIN) ) {
>                                                                      
> # do something with "$dirname/$file"
> 
> @ARGV = qw# $file # ;                                       # <------
> this is not right ?
> 
> while (<>) {
> 
>      /$RE{URI}{HTTP}/       and  print "Contains an HTTP URI.\n";
>   }
> 
>  closedir (BIN);
> 
> }


To load @ARGV, you can use:

   @ARGV = grep -f, map "$dir/$_", readdir BIN;

or use glob():

   @ARGV = grep -f, glob '/Program\ Files/OptiPerl/test_files/*';

The grep is to include only plain files and not directories.

Your loop can be something like:

   while (<>) {
       print "$ARGV contains an HTTP URI\n" and close(ARGV) and next
           if /$RE{URI}{HTTP}/;
   }


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