Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 870233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:26:17+00:00 2026-05-15T10:26:17+00:00

I use File::Find -> find(\&f, $directory) for find some file with some content. Relevant

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:26:18+00:00Added an answer on May 15, 2026 at 10:26 am

    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:

    #!/usr/bin/perl
    
    use strict;
    use File::Find;
    use Cwd;
    
    print "++ With relative path ++\n";
    find(\&f, ".");
    
    print "\n++ With current working directory module ++\n";
    find(\&f, cwd);
    
    sub f
    {
            my $file = $File::Find::name;
            print $file . ":\n";
    
            if (-f $file) { print "---- ist Datai\n"; }
            else { print "---- ist nicht eine Datei!!!\n"; }
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perl question for you: #!/usr/bin/perl use File::Find; #Find files find(\&wanted, $dir); sub wanted {
I wanted to use find to find every file in a directory that starts
I have code like below. If I open the file $File::Find::name (in this case
I am trying to find a file in a root directory and it's sub-directories.
I want to use regular expression to find strings in a file that have
How can I use the autoloader to find the class file 'templater' that lives
I would like to have a nice easy to use file upload system on
The application i'm developing uses a certain file directory structure. Via the use of
In Perl we usually do a recursive directory traversal using File::Find and we often
File in: compute = ...page.
o When you use the “Create Form” function ... Do...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.