This reply is hard for me to understand. The whole idea of this is to set the $yr and $day, etc. variables!
my (undef, $min, $hr, $day, $mon, $year) = localtime();
and
my ($min, $hr, $day, $mon, $year) = (localtime())[1..5];
mean exactly the same thing.
Perhaps one point of confusion is that your statements like my $year; are completely unnecessary. That creates the variable $year and assigns it the value of undef. In general, combine the creation of the variable and the assignment of useful value to it into one statement. There is no need to have a list of my $year; type of statements before assigning values to them. Also limit the use of these newly created "my" variables to the smallest scope practical.
In general, $_ , the "default variable", "belongs to Perl" - meaning that is something Perl sets and you read, but you never set or write to yourself. There are of course exceptions to this. However, for your first few hundred programs, you are unlikely to happen across one of these exceptions.
|