Help
I need this variable $time to show last hour (00..23) So if hour is 00, I want 23. If hour is 01, I want 00, etc.....
I can run that awk statement on the command line and it works great, but if I try it in the script it fails with an awk syntax error...
Is there a way to look at last hour with $time1 ?? I would rather keep it all perl.....
Use Perl Date/Time manipulation modules.
Reasoning: 00:00 is a new day - therefore 23:00 (an hour earlier) is also yesterday (the day before) -- you dont seem to account for this inconsisitency.
If you do not need that fine a date/time set - then just do:
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime;
printf("Last hour was %d", (($hour) ? $hour - 1 : 23 ));
__END__
-Sx-
# Example of DATE: Tue Feb 2 19:34:24 EST 1999 my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
my ($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime;
# ( 00 20 20 16 10 63 06 197 01); # Last two not used...
# Ex: $days[$wday] $months[$mon] $mday $hour:$min:$sec $year
my $today = $months[$mon] . " " . sprintf("%2d", $mday); # Get just today's Date...
my $ntday = sprintf("%02d", $mon + 1) . '/' . sprintf("%02d", $mday); # Get just today's Numbers...
my $xfday = $days[$wday] . " " . $months[$mon] . " " . sprintf("%2d", $mday); # xferlog Date format...
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>