[Chicago-talk] get array element from a function return

Young, Darren Darren.Young at chicagobooth.edu
Fri Dec 3 12:09:00 PST 2010


> Hi,
> To get the weekday name of current day in Perl, I am using some thing like below. I do not like so many 
> punctuation marks. Can it be simpler?
>
> perl -le 'print [("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat")]->[[localtime(time)]->[6]]'

use POSIX qw(strftime);
$wday = strftime "%a", localtime;
print $wday . "\n";


More information about the Chicago-talk mailing list