CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [FishMonger] Copy and Delete File: Edit Log


May 24, 2013, 8:44 AM

Views: 1059
Re: [FishMonger] Copy and Delete File

Sticking to simple, here is an option.

use strict;                                       #use strict.. 
use warnings; #use warnings..
use File::Copy;

my $old_path = '/path/to/old/dir'; # Path to your directory of files
my $new_path = '/path/to/new/dir'; # Path to the new directory

opendir my $dh, $old_path or die "failed: $!\n"; # Opening directory of files here
my @wanted = grep /(?i)ABC/, readdir $dh; # Match for filenames with ABC

foreach my $file (@wanted) { # Loop through list of matched files
if (-f "$old_path/$file" ) { # we found and do something...
# do something...

closedir $dh;

(This post was edited by hwnd on May 24, 2013, 10:25 AM)

Edit Log:
Post edited by hwnd (User) on May 24, 2013, 10:25 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives