in reply to Re^2: Date Handling in Perl
in thread Date Handling in Perl

The code is better written as:

$_ = $hour > 10 ? 0 : 60*60*24; # seconds in the day my ($mday,$mon,$year) = (localtime(time-$_))[3..5];

Using $_ here is just laziness of not declaring a new variable. The first line returns 0 if hour <= 10, and 86400 otherwise. It is then used to modify the time() function to either get today's date (when 0) or yesterday's (when 86400).

(I do wonder where that corruption of the ternary operator comes from. It makes no sense at all. Unless someone is teaching it as a "shorthand if"...)