in reply to [Updated] (localtime) versus localtime - round 1
localtime returns a list and ( )[0..2] is a list slice that narrows down that list to the first three elements. localtime also accepts a numerical argument (usually time) but the number you are supplying in the second example is a reference to an anonymous array (localtime[0..2] is the same as localtime\@array). But as you are reading from the beginning of the list you don't really need the list slice at all:
my ($sec, $min, $hour) = localtime;
Will do the same as the first example.
|
|---|