Thread File::Find - Suche Files (3 answers)
Opened by Astralkeks at 2012-08-14 17:06

Astralkeks
 2012-08-14 17:06
#160922 #160922
User since
2012-07-17
40 Artikel
BenutzerIn
[default_avatar]
Hallo,

Problem ist folgendes:
Ich suche Dateien in einem Ordner. Die Dateinamen (ohne Pfad, den will ich ja herausfinden) kommen aus einer Datei, in der in jeder Zeile nur die zu suchende Datei steht.

Code (perl): (dl )
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;
        
}

Ich erhalte als Fehler:
Name "File::Find::Name" Used only once: possible typo

und in den Arrayelementen wird jeweils "Use of uninitialized Value" angemeckert.
Kann doch eigentlich nicht so schwer sein, oder?

View full thread File::Find - Suche Files