first off, the broken code;
Code:
#!/usr/bin/perl
#pragmas
use strict;
#modules
use File::Find ();
#declaring global variables
use vars qw/@filenames/;
@filenames = (File::Find::find(\&getfiles, "/some/dir/here"));
foreach (@filenames) {
print "$_\n";
}
sub getfiles {
if (/part_of_filename/ && (int(-M) < 1)) {
unshift @filenames, $File::Find::name;
}
chomp(@filenames);
return @filenames;
}
I want this to print each absolute filename that matches the if test in my getfiles subroutine but it just prints a blank line and ends. I do realize that
Code:
sub getfiles {
if (/part_of_filename/ && (int(-M) < 1)) {
print "$File::Find::name\n";
}
}
does what I am asking for. I intend to do much more with that list of filenames later, but I haven't written the rest because this part doesn't work yet.