in reply to Re: File::Find help
in thread File::Find help

Hi, Thank you for the reply. My dilemma is that the file (-f) could be way under multiple subdirectories. How can I effectively capture those so I can pass that to a variable to later do the unlink?

Replies are listed 'Best First'.
Re^3: File::Find help
by Corion (Patriarch) on Dec 02, 2017 at 10:07 UTC

    Whenever you find a directory, remember it to be deleted afterwards?

    my @to_be_deleted; File::Find( ..., sub { if( -d $File::Find::name ) { print "'$File::Find::name' should be deleted later\n"; # push @to_be_deleted, $File::Find::name; }; }; rmdir @to_be_deleted; # boom

      great thanks much!... Follow-up to this, I hope you could also help me below: How about using Find::File to copy the subfolder + filename to another folder. Like: DIR_A/SUB_A/FILE_A ----> DIR_B/SUB_A/FILE_A Appreciate much your inputs.