in reply to Picking up files based on datestamp

Dear all

Thank you all for your inputs. I can manage the regexp part, but the main problem is identifying yesterday's "yyyymmdd" value.

Sivakumar: I cant install any external modules as of now (sucks, but well..) and I dont have the DateTime::Precise module.

How do I identify yesterday's $yyyymmdd value using the default modules/functions?

Help!

Thanks & regards,

Subhankar
  • Comment on Re: Picking up files based on datestamp

Replies are listed 'Best First'.
Re^2: Picking up files based on datestamp
by siva kumar (Pilgrim) on Sep 19, 2007 at 10:22 UTC
    you can find yesterday's yyyymmdd using
    my $timestampminus = time - 24 * 60 * 60; my ($year, $month, $day) = (localtime($timestampminus))[5,4,3]; $year += 1900; $month++; print "Yesterday was $year$month$day.\n";
Re^2: Picking up files based on datestamp
by johngg (Canon) on Sep 19, 2007 at 10:27 UTC
    Use time and localtime.

    my ($day, $month, $year) = (localtime(time() - 86400))[3, 4, 5]; $month += 1; $year += 1900;

    I hope this is of use.

    Cheers,

    JohnGG

      time() - 86400

      Beware that this calculation is correct only if days are 24 hours long. Not all of mine are. :)

      perldoc -q yesterday

      -pilcrow