I thought of that right after hitting send...
 
This may be better if he wants to do a lot of date manipulation down the road:
 
#!/usr/bin/perl -w
 
use Date::Manip;
 
my ($day, $mnth, $yr);
my $date = DateCalc("today","- 1day");
($yr, $mnth, $day) = ($date =~ /(\d\d\d\d)(\d\d)(\d\d)/);
print "Yesterday was $mnth/$day/$yr\n";



>>> Bob Showalter <[EMAIL PROTECTED]> 10/10/03 12:20PM >>>
Bill Akins wrote:
> ...
> Try this:
> #!/usr/bin/perl -w
> 
> my @now     = localtime;
> my $sec     = ( $now[0] );
> my $min     = ( $now[1] );
> my $hr      = ( $now[2] );
> my $day     = ( $now[3] );
> my $mth     = ( $now[4] + 1 );
> my $yr      = ( $now[5] + 1900 );
> 
> $day = ($day -1);
> print "Yesterday was $mth/$day/$yr\nor if on the other side
> of the pond, $day/$mth/$yr\n";

What if today is the first of the month?

Better to use something like:

   ($d, $m, $y) = (localtime(time - 86_400))[3..5];
   $m++;
   $y += 1900;

IOW, have the system calculate local time for current epoch - 86,400
seconds (# of seconds in a day).


Reply via email to