use constant MONTHS => 'JanFebMarAprMayJunJulAugSepOctNovDec'; ... my $month_num = index(MONTHS, $month_str)/3;
Better still?
Unfortunately, this (against my expectations) turns out to be between 30% & 50% slower than the hash solution.
It uses much less momory, but it seems that hashing a 3 char string, indexing and returning the value is faster than a linear search for a 3 char string + a division.
Surprised me
Examine what is said, not who speaks.
In reply to Re: Re^4: Pulling by regex II
by BrowserUk
in thread Pulling by regex II
by mkent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |