note: I am fairly new to perl
I have 2 dirs one contains files with sequential filenames
( 12345.dat, 12346.dat, 12347.dat etc..)
the other contains similar filenames but with an alpha prefix (A23456.dat, F23457.dat, S23458.dat etc..)
I need to create a list that contains the filenames of both dirs -with the newest filenames (higest sequential number regardless of prefix) from both at the top
the code i am using (at the moment) for generating my list is:
opendir THEDIR, "$dirpath" || die "cant open $dirpath !";
@allfiles = grep /^(?:158|159)/,readdir THEDIR;
closedir THEDIR;
foreach $file (sort { ($b) cmp ($a) } @allfiles) {
print "$file\n";}
please don't laugh..it took me a LONG time to get that to work. As you can see to make it all go a bit faster i have limited the list to only filenames that start with either 158 or 159. What I need to do is somehow get the contents of the other dir into this list whilst still keeping the newest filenames at the top.
ps I'm not asking for a complete script just a few pointers as to how to go about doing it.
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.