I'm looking to grab the current month and current year to default in a form, but I don't want to create an array. Can I access the localtime elements directly with localtime[0] or is there another method.
In addition to the list slices and list assignments with undef on the LHS, you can also opt to use POSIX::strftime. This also takes the way the need to add 1 to the month and 1900 to the year. As I don't see the point in having separate variables for this, I guess you're building an ISO date in "2005-01" format.
use POSIX qw(strftime); my $month = strftime "%Y-%m", localtime;
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
In reply to Re: Fetching Only Month and Year From localtime()
by Juerd
in thread Fetching Only Month and Year From localtime()
by amt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |