This little snippet works fine to grab a (compressed) file name and it's time stamp, but I'm sure that the regexp part could be written better. Also, does it have to be in an "if" statement?
chomp($ll[0] = `ls -lto $path/*B1006* |head -n 1`);
chomp($ll[1] = `ls -lto $path/*B1106-* |head -n 1`);
chomp($ll[2] = `ls -lto $path/*B11062* |head -n 1`);
$next = 0;
foreach (@ll) {
if (m#([A-Z][a-z][a-z]\s[0-9][0-9]\s[0-9][0-9]:[0-9][0-9])\s(/.+\.
+Z)#) {
$stamp[$next] = $1;
$name[$next] = $2;
}
print "\$name[\$next]: $name[$next]\n";
print "\$stamp[\$next]: $stamp[$next]\n";
$next++;
}
The Output looks like this:
$name[$next]: /<path>/B1006-cnvexp.20060605.200841.Z
$stamp[$next]: Jun 05 20:08
$name[$next]: /<path>/B1106-cnvexp.20060605.2008.Z
$stamp[$next]: Jun 05 20:09
$name[$next]: /<path>/B11062-cnvexp.20060605.2008.Z
$stamp[$next]: Jun 05 20:09
I am the young grasshopper. In one hour, I will be off work and practicing my drunken style :) Cheers.
2006-06-06 Retitled by planetscape, as per Monastery guidelines
( keep:0 edit:11 reap:0 )
Original title: 'Tips for elegence'
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.