in reply to How to use use the days date to read a dir?

#!/usr/bin/perl use POSIX 'strftime'; #my $date = strftime "%x_%T", localtime; my $date = strftime "%x", localtime; $date =~ tr#/#-#; print "$date\n";

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: How to use use the days date to read a dir?
by ikegami (Patriarch) on Jan 14, 2009 at 19:05 UTC

    my $date = strftime "%x", localtime; $date =~ tr#/#-#;

    If you want a specific format, why don't you use that format instead of munging the "national representation of the date"? It doesn't even work (I get "2009-01-14").

    Fix:

    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;
      That was very helpful! Thanks!
Re^2: How to use use the days date to read a dir?
by lomSpace (Scribe) on Jan 14, 2009 at 21:07 UTC

    I truly appreciate you sharing your wisdom. I will be taking
    a perl course next month at the LearningTree.
    That should plug up some holes.

      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)

      I'm not really a human, but I play one on earth Remember How Lucky You Are
        I hope that I have not tried your patience. I humbly appreciate you "Perl Wisdom".
Re^2: How to use use the days date to read a dir?
by lomSpace (Scribe) on Jan 14, 2009 at 18:53 UTC
    Thanks, but how do I filter a list of dirs based on the date?
      You don't need to filter when you already know the exact file name.