Hi all..... as a means of learning Perl, I am writing a script to search for files of various extensions. Here is a little snippet to show you my issue. The output shows that only files ending in "txt" are being found.... am I over writing @files every time thus only the last $ext survives? If so, how should the script read to put all file paths of all types in @type into @files.
lol... sorry if this makes no scene.... been a VERY long day.. time for bed!
Quote:
#!/usr/bin/perl -w
use File::List;
my @type = ("html", "mp3", "txt");
foreach $ext (@type) {
$search = new File::List("/home/mine");
@files = @{ $search->find("\.$ext\$")};
}
print "\n\n";
foreach $file (@files) {
print "$file\n";
}
print "\n\n";
foreach $ext (@type) {
print "$ext\n";
}
|
Output is:
Quote:
/home/mcy/.mozilla/firefox/wkidzzc0.default/cert_override.txt
/home/mcy/.mozilla/firefox/wkidzzc0.default/signons3.txt
/home/mcy/.mozilla/firefox/wkidzzc0.default/urlclassifierkey3.txt
/home/mcy/readme.txt
html
mp3
txt
|