It sounds to me like you don't want files "BSC", "SBSCSubsystem", and "MCBTSSubsystem", but rather directories, and to have the 20041202 files prefixed with those moved into the directories?
If so, try doing one category at a time:
for my $category ("BSC", "SBSCSubsystem", "MCBTSSubsystem") {
}
Inside the loop you'll need to:
- create the directory if it doesn't exist, like:
use Errno "EEXIST";
if (! mkdir("foo") && $! != EEXIST) { die "unable to create directory
+foo: $!" }
- find any matching files and put them in @files. I wouldn't use a regular expression; I'd just use glob.
- move @files into your directory. No File I/O required, rename($file, "dirname/$file") should work to move $file from the current directory into directory dirname.
Update: added use Errno
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.