my ($lastMod) = (head($url))[2];
you lose any distinction between head() failing (which returns an empty list) and head succeeding but modtime not being available. If you need to differentiate between the two, you can do it (without introducing any temp variables) by saying:
if (my (undef,undef,$lastMod) = head($url)) {
# success
if (!defined $lastMod) {
# but alas no mod time
}
}
or even
my $gotHead = (my (undef,undef,$lastMod) = head($url));
This are instances of a list assignment in scalar context, which yields the number of entries in the list on the right hand side of the assignment (5 if head succeeded, 0 if it failed). |