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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:28:49+00:00 2026-06-05T08:28:49+00:00

So essentially what I’m trying to do is go through a directory and perform

  • 0

So essentially what I’m trying to do is go through a directory and perform an action on all of the files, in this case, the sub searchForErrors. This sub works. What I have so far is:

sub proccessFiles{
    my $path = $ARGV[2];

    opendir(DIR, $path) or die "Unable to open $path: $!";
    my @files = readdir(DIR);
    @files = map{$path . '/' . $_ } @files;
    closedir(DIR);

    for (@files){
        if(-d $_){
            process_files($_);
        }
        else{
        searchForErrors;
    }
}
}

proccessFiles($path);

Any help/suggestions would be great. And again, I’m new to Perl, so the more explanation the better. Thank you!

  • 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-06-05T08:28:50+00:00Added an answer on June 5, 2026 at 8:28 am

    You should use the File::Find module instead of trying to reinvent the wheel:

    use strict;
    use warnings;
    use File::Find;
    
    my @files;
    my $start_dir = "somedir";  # top level dir to search
    find( 
        sub { push @files, $File::Find::name unless -d; }, 
        $start_dir
    );
    for my $file (@files) {
        searchForErrors($file); 
    }
    

    A problem with your current code is that you are including . and .. directories in your recursive search, which will no doubt cause deep recursion errors.

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

Sidebar

Related Questions

Essentially I would like to have a messages.properties files external to the jar files
Essentially, I have three coordinates in play. Cleveland, TN -- (35.255097,-84.86844) -- This is
Essentially the title of this question explains the essense of what I am trying
Essentially my problem is thus; I have a MVC system that redirects all requests
Essentially what I'm trying to do at this point is build a program to
Essentially, I have to get a flat file into a database. The flat files
Essentially, my question is this: There are two ways that I have experienced setting
Essentially what I have is this structure: PHP Application -> PHP Extension (in C++)
essentially I have a textbox on my webpage, and I'm trying to add a
Essentially I have a method of a class called killProgram, which is intended to

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.