Re: How to use use the days date to read a dir?
by Fletch (Bishop) on Jan 14, 2009 at 18:15 UTC
|
Feed the output from localtime into an appropriately crafted call to strftime from the core POSIX module.
The cake is a lie.
The cake is a lie.
The cake is a lie.
| [reply] [d/l] |
Re: How to use use the days date to read a dir?
by ww (Archbishop) on Jan 14, 2009 at 19:39 UTC
|
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
| [reply] |
Re: How to use use the days date to read a dir?
by zentara (Cardinal) on Jan 14, 2009 at 18:14 UTC
|
#!/usr/bin/perl
use POSIX 'strftime';
#my $date = strftime "%x_%T", localtime;
my $date = strftime "%x", localtime;
$date =~ tr#/#-#;
print "$date\n";
| [reply] [d/l] |
|
|
use POSIX qw( strftime );
my $date = strftime "%m-%d-%y", localtime;
print "$date\n";
But since he didn't ask for the date, he'd want
my $dir = strftime "Results %m-%d-%y", localtime;
| [reply] [d/l] [select] |
|
|
That was very helpful! Thanks!
| [reply] |
|
|
| [reply] |
|
|
Some advice: you learn more by trying to find answers yourself. Then if all else fails, ask here. Searching google and groups.google.com will give you all the answers you probably need as a beginner. Search google for "perl grep files" or "perl grep directories", etc. All we do here, is repeat what was already answered many times before, and is stored in google.(or the searchbox/tutorials here at perlmonks)
| [reply] |
|
|
|
|
|
|
Thanks, but how do I filter a list of dirs based on the date?
| [reply] |
|
|
You don't need to filter when you already know the exact file name.
| [reply] |
Re: How to use use the days date to read a dir?
by JavaFan (Canon) on Jan 14, 2009 at 18:15 UTC
|
Start with perldoc -f localtime and come back if you have more specific questions. | [reply] |
|
|
I need to filter a glob based on the current date. I only want the most current dirs. Ex. today is 01-14-09. I only want that part of the glob. How do you grep that?
| [reply] |
|
|
| [reply] |
|
|
|
|