I use File::Find -> find(\&f, $directory) for find some file with some content.
Relevant part of my delegate looks like:
sub f {
my $file = $File::Find::name;
return unless -f $file;
return unless $file =~ /$file_pattern/;
etc...
but the problem is that, that this code returns every time where $file not exist in current directory.
For example for file ./test it fine, but for file ./dir/test this return…
Is there some better way to know if $file is file?
Thank you all for replays, but you are wrong 🙂
Here is some bug. It work only with full path.
I perform some test. Here is the code:
Here are the commands:
[andrey@andreys-comp testdir]$ ls -l innerdir/
total 4
-rw-rw-r– 1 andrey andrey 0 Jun 18 22:02 innertestfile
[andrey@andreys-comp testdir]$ ./test.pl
++ With relative path ++
.:
—- ist nicht eine Datei!!!
./test.pl:
—- ist Datai
./testfile:
—- ist Datai
./innerdir:
—- ist nicht eine Datei!!!
./innerdir/innertestfile:
—- ist nicht eine Datei!!!
++ With current working directory module ++
/home/andrey/testdir:
—- ist nicht eine Datei!!!
/home/andrey/testdir/test.pl:
—- ist Datai
/home/andrey/testdir/testfile:
—- ist Datai
/home/andrey/testdir/innerdir:
—- ist nicht eine Datei!!!
/home/andrey/testdir/innerdir/innertestfile:
—- ist Datai
ist Datei: is file
ist nicht eine Datei: is not file (I just like German 🙂 )
Put your attension that in first method ./innerdir/innertestfile not determined as file, rather than in second.