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);
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>