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 3285700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:17:46+00:00 2026-05-17T20:17:46+00:00

Perl question for you: #!/usr/bin/perl use File::Find; #Find files find(\&wanted, $dir); sub wanted {

  • 0

Perl question for you:

#!/usr/bin/perl
use File::Find;

#Find files
find(\&wanted, $dir);

sub wanted {    #Do something   }   
#Done going through all files, do below:

other stuff { }

So, I basically want to parse a directory and find certain kinds of files. I can do that successfully with File::Find. However, my next step is, once I’m done searching the files, I want to do my next process.

The problem is , whatever, I put after the sub wanted { #Do something } , gets executed, everytime, the file I want is not found! I know this is only logical for the program to do that. But, could you tell me what I’d need to do to accomplish this:

1] Find files : using > sub wanted { #Do something }
2] While no more files to search : >do something else { }

Thanks!

  • 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-17T20:17:47+00:00Added an answer on May 17, 2026 at 8:17 pm

    UPDATED ANSWER: (after OP clarified that he simply wants to run some code after find() finishes searching):

    Since find() is not searching in parallel, it will simply return when all of the search is completed. Therefore you don’t need to do ANYTHING special to achieve your goal:

    find(\&wanted, @directories_to_search);
    # Here be code that runs after search completes.
    

    ORIGINAL ANSWER

    You can set founding of files flag in wanted subroutine:

    my $files_not_found = 1;
    find(\&wanted, @directories_to_search);
    sub wanted { @args=@_; $files_not_found = 0; }
    if ($files_not_found) { 
        print "No files found!\n";
    }
    # Here you do things after find is finished.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perl seems to be killing my array whenever I read a file: my @files
Really simple perl question, but confusing me greatly. foreach $val (@{$obj->something()}) { # this
I'm modifying a mature CGI application written in Perl and the question of content
On researching another question I noted that the stat function in Perl can take
PERL? Perl? perl? What's good style? I know the answer—I just wanted to make
I create the following XML file, by perl script (Showing down) , using XML::LibXML:
the following perl script (Showing down) print the following XML file but the XML
I have perl 5.10.1 installed on my ubuntu machine. I wanted to install the
This is a continuation of my original question: Perl- How do I insert a
I have some questions about Perl's map function. Specifically: How does %hash = map

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.