Here's a complete solution to your problem. Assuming that
the file that interests you is one of a group of files
that are all in the form
of
mlb_boxscore$0000200.txt with
the number portion 7 digits and
zero-padded and the file you want always being the one with
the hightest number, this will get you the name of the file
you want:
opendir DIR, "/path/to/mlb/incomingdir";
my ($todays_file) = reverse sort readdir(DIR);
closedir DIR;
If there are other files in the directory in question that
we need to ignore, you'll need a little more:
opendir DIR, "/path/to/mlb/incomingdir";
my ($todays_file) = reverse
sort
grep {/mlb_boxscore\$\d{7}\.txt/}
readdir(DIR);
closedir DIR;
Now you can open
$todays_file and process
it as you like.
Sorry about the funny formatting of the crucial line to get
it to fit here. If you like in your own code you can lay
it all down in one line thusly:
my ($todays_file) = reverse sort grep {/mlb_boxscore\$\d{7}\.txt/} readdir(DIR);
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.