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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:05:30+00:00 2026-05-23T02:05:30+00:00

This is how I currently delete files and directories recursively foreach my $row(keys %$rows)

  • 0

This is how I currently delete files and directories recursively

foreach my $row(keys %$rows)
{
    my $md5 = $rows->{$row}->{'md5'};
    my $path = "/some/path/jpg/".substr( $md5, 0, 3 )."/$md5";

    `rm -rf $path`;
    print "removed - ".$path."\n";
}

There are hundreds of thousands of files/dirs that need to be deleted, so I would like to see a better solution other than calling “rm -rf” for each file/dir.

Maybe combine a list of files/dirs in array and then pass this array to a single “rm -rf” call?

  • 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-23T02:05:31+00:00Added an answer on May 23, 2026 at 2:05 am

    Use rmtree from File::Path. In addition to being portable, it uses Perl’s builtin unlink instead of firing up a whole shell every time you need to delete a directory, which is what you’re doing now.

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

Sidebar

Related Questions

i currently use this code to delete a folder and its contents: string tempFolder
This is currently what I have to delete the file but it's not working.
Currently I have some code deleting some temporary files created by my program: #
I have something like this currently: <div class = className style = position: absolute;
I have a relatively complex .htaccess file to control page requests, this currently redirects
this is currently my code byte[] bytes = { 0x42, 0x1c, 00, 00 };
This is currently my htacess file: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond
This program currently inputs an image of a coin, thresholds it, binarizes it, and
Currently this expression I ([a-zA-z]\d]{3} returns when the following pattern is true: I AAA
There is currently this Prototype code that does a PUT: new Ajax.Request(someUrl, { method:

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.