1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/usr/bin/perl -w use strict; use File::Find; my $result = "result.txt"; my $dir = "C:\\test\\"; findFiles(); sub findFiles { my $tmp; my @found = (); open (FILE, "<$result"); while(<FILE>){ $tmp = $_; chomp ($tmp); find(sub {if ($_ =~ /$tmp/){push @found, $File::Find::Name}}, $dir); } close FILE; print @found; }
2012-08-14T15:06:13 AstralkeksIch erhalte als Fehler:
Name "File::Find::Name" Used only once: possible typo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#!/usr/bin/perl -w use strict; use File::Find; my $result = "result.txt"; my $dir = "C:\\test\\"; my @files=findFiles($result,$dir); print join("\n", @files),"\n"; sub findFiles { my $file=shift; my @dirs=@_; open (my $fh, "<", $file); while(my $regexp=<$fh>) { chomp ($regexp); find(sub { push( @found, $File::Find::name ) if ($_ =~ /$regexp/); }, @dirs); } close $fh; return @found; }