in reply to Reading log file for current date

I refactored your get_cur_time function, and renamed it as print_cur_time:
#!/usr/bin/env perl use warnings; use strict; print_cur_time(); exit; sub print_cur_time { my ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time); $Year += 1900; $Month = sprintf '%02d', $Month + 1; $Day = sprintf '%02d', $Day; $Hour = sprintf '%02d', $Hour; $Minute = sprintf '%02d', $Minute; $Second = sprintf '%02d', $Second; print "Today's Date is: $Month/$Day/$Year $Hour:$Minute:$Second\n" +; }

I just wanted to point out that you can use sprintf to pad a zero to single-digit numbers. I hope this is of use to you.

Replies are listed 'Best First'.
Re^2: Reading log file for current date
by raj8 (Sexton) on Feb 24, 2008 at 01:45 UTC
    Yes, that was very helpful and reduced the code. Thank you!