How to determinate file in Perl

Posted by rodnower on Stack Overflow See other posts from Stack Overflow or by rodnower
Published on 2010-06-16T08:08:55Z Indexed on 2010/06/16 8:12 UTC
Read the original article Hit count: 131

Filed under:
|

Hello, 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?

© Stack Overflow or respective owner

Related posts about linux

Related posts about perl