Assigning pattern matches to an array



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


.



Relevant Pages

  • Re: smash and grab
    ... close HOST or die $!; ... foreach $box (@boxes) { ... print DENY "$tim\n"; ...
    (perl.beginners)
  • Re: system call issues
    ... foreach $protein { ... foreach $protein2 { ... close TEMP; ... or die "Cannot open pipe from 'TMalign' $!": ...
    (perl.beginners)
  • Re: Open All files one by one
    ... foreach $line { ... sub ReadFile{ ... my $file = shift @_; ... open or die "Could not open file $file"; ...
    (comp.lang.perl.misc)
  • Perl Script - Not Getting Results When Using Command Line Arguments
    ... @SORTED_DIRLIST = sort @DIRLIST; ... # foreach $result ... die "$helpfile"; ... The only section that works is the first one with no command line ...
    (perl.beginners)
  • Re: smash and grab
    ... Tim Wolak wrote: ... close HOST or die $!; ... foreach $box { ... print DENY "$tim\n"; ...
    (perl.beginners)