in reply to Printing Fixed Width Strings and Spliting String into Multiple Lines
my ($mon, $year) = (localtime())[4, 5];
And for finding the name of the month I use a list:
my $month = (qw/January February March April May June July August Sept +ember October November December/)[(localtime())[4]];
And combining all together (without using any intermediary variables):
$month_year= (qw/January February March April May June July August Sep +tember October November December/)[(localtime())[4]] . (1900 + (local +time())[5]);
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing Fixed Width Strings and Spliting String into Multiple Lines
by mmartin (Monk) on Feb 09, 2012 at 20:04 UTC |