> -----Original Message-----
> From: EWALKER 1016705 [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 15, 2005 2:20 PM
> To: beginners@perl.org
> Cc: Brian Volk
> Subject: Re: /$RE{URI}{HTTP}{-keep}/;
> 
> 
> On Tuesday 15 February 2005 11:06 am, Brian Volk wrote:
> > #!/usr/bin/perl
> >  
> > use warnings;
> > use strict;
> > use Cwd;
> > use File::Basename;
> > use Regexp::Common qw /URI/;
> >  
> > my $dir = "C:/brian/small";
> >  opendir (SM, $dir) or die "Can't open $dir: $!";
> >  
> > my @files = map { "$dir/$_" } grep { !/^\./ } readdir SM;
> >  
> > close SM;
> >  
> > foreach my $file (@files) {
> >     my ($basename) = fileparse($file,'.txt');
> >        
> >        open(LINK, "> $basename.txt") or warn "$!\n";
> >        my $text = '';
> >        open(TEXT, "< $file") or warn "$!\n";
> >        read( TEXT, $text, -s TEXT );      
> >        print LINK "$text $1\n"                              
>     # <------
> > Use of uninitialized value in pattern match
> >        and close TEXT and next
> >        if /$RE{URI}{HTTP}{-keep}/;
> >        
> >     }
> >
> > # ----- end
> 
> I don't have the rex module be I was able to get a crude 
> version running I am 
> sure others have better ways of doing it. I think this works 
> didn't test it 
> out fully.
> 
> my $dir = "C:/brian/small";
> opendir (SM, $dir) or die "Can't open $dir: $!";
> my $text; 
> #my @files = map { "$dir/$_" } grep { !/^\./ } readdir SM;
> my @files = grep /.txt/, readdir SM;
>  
> close SM;
> 
> 
> 
> 
> 
> foreach my $file (@files) {
>     chomp;
>     my ($basename) = fileparse($file,'.txt');
>        
>       open(LINK, ">./newfiles/$basename.txt") or warn "$!\n";
>        my $text = '';
>        open(TEXT, "< $file") or warn "$!\n";
>        #read( TEXT, $text, -s TEXT );       
>        while(<LINK> {
>             need an expression here to pull the link out of 
> the current
>             line if there is one.
>             print LINK "$text $1\n"                   
>             }
>         close(LINK);
>         close(TEXT);
>  
>     }

Thank you, the while loop makes a lot of sense..  I'm getting the new files
to print to the CWD but there are still empty..  ( yes, there are URL's in
some of the files .. :~) ) ... I tried the rex mod becaue I have it working
in another program..  but that is writing the url's into one big file.  Now
I'm getting the error.. 
"Filehandle LINK opened only for output"  Not sure what's happening 

-- revised 

use warnings;
use strict;
use Cwd;
use File::Basename;
use Regexp::Common qw /URI/;

# my $dir = "J:/flash_host/ecomm/descriptions/product/small";
my $dir = "C:/brian/small";
 opendir (SM, $dir) or die "Can't open $dir: $!";

my @files = map { "$dir/$_" } grep { !/^\./ } readdir SM;

close SM;

 
foreach my $file (@files) {

    my ($basename) = fileparse($file,'.txt');
       
      open(LINK, "> $basename.txt") or warn "$!\n";
       my $text = '';
       open(TEXT, "< $file") or warn "$!\n";
       read( TEXT, $text, -s TEXT );       
       while(<LINK>){                              
            print LINK "$text $1\n"
            if /$RE{URI}{HTTP}{-keep}/;  
           }  

        close(LINK);
        close(TEXT);
   }

-- end



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