in reply to Processing data in on dir and copying, then processing into another dir
#!/usr/bin/perl use warnings; use strict; # goes from current dir, and looks thru # a subdir named 7, for subdirs starting with # Jan_2009_, then goes into that subdir and finds # files begiining with a or b or c # making your particular regexes is up to you my $topdir = '7'; my @subdirs = get_sub_dirs($topdir); sub get_sub_dirs { my $dir = shift; opendir my $dh, $dir or die "Error: $!"; my @dirs = readdir $dh; @dirs = grep /^Jan_2009_(.*)$/,@dirs; closedir $dh; return @dirs; } print "@subdirs\n"; my @files; foreach my $dir(@subdirs){ opendir my $dh, "$topdir/$dir" or die "Error: $!"; @files = readdir $dh; @files = grep /^(a|b|c)(.*)$/,@files; closedir $dh; } print "@files\n"; #Now you can regex your files, etc
|
|---|