in reply to Yesterday Date

Date::Simple to the help.

#!/usr/bin/perl use strict; use warnings; use Date::Simple qw(today); my $d = today() - 1; $d-- while ($d->day_of_week == 0 or $d->day_of_week == 6); print $d, $/;

Replies are listed 'Best First'.
Re^2: Yesterday Date
by Anonymous Monk on Feb 04, 2008 at 19:54 UTC
    This gets the right date and no weekend, can you explain what this code is doing, specially the "$d--" ? Is there another way to write the some code?
      $d-- is short for $d = $d -1, that is "subtract one from $d".

      Date::Simple provides a date object, and you can add and subtract number from that, so today() - 1 is yesterday.

      Then it decreases the value by one while the day of week is 0 (Sunday) or 6 (Saturday).

        OK, it could be written like:
        if( ($d->day_of_week == 0) ||( $d->day_of_week == 6)){ $d = $d -1; print $d; }