G
Graham Stow
The following is a crude attempt at matching occurrences of email addresses
within files in a directory. However, I can't figure out why line 15 doesn't
assign the pattern matches to the @matches array. Any ideas gang, or have I
been eating too much turkey?
#!/usr/local/bin/perl
use File::Find;
@directories = ("c:/email2");
find (\&wanted, @directories);
sub wanted {
$filename=$File::Find::name;
if ($filename =~ /\.\w{3}$/) {
push(@files, $filename);
}
}
foreach $file (@files) {
open (DATA, "$file") || die "Error opening $file\n";
@whole_file = <DATA>;
foreach $line (@whole_file) {
@matches = /\b\w+@\w+\b/g;
}
close DATA || die "Unable to close $file\n";
# closes the current file
}
foreach $match (@matches) {
print "$match\n";
}
$count += @matches;
print "$count matches\n";
within files in a directory. However, I can't figure out why line 15 doesn't
assign the pattern matches to the @matches array. Any ideas gang, or have I
been eating too much turkey?
#!/usr/local/bin/perl
use File::Find;
@directories = ("c:/email2");
find (\&wanted, @directories);
sub wanted {
$filename=$File::Find::name;
if ($filename =~ /\.\w{3}$/) {
push(@files, $filename);
}
}
foreach $file (@files) {
open (DATA, "$file") || die "Error opening $file\n";
@whole_file = <DATA>;
foreach $line (@whole_file) {
@matches = /\b\w+@\w+\b/g;
}
close DATA || die "Unable to close $file\n";
# closes the current file
}
foreach $match (@matches) {
print "$match\n";
}
$count += @matches;
print "$count matches\n";