in reply to Re^8: Speeding up named capture buffer access
in thread Speeding up named capture buffer access
If you are willing to trade a few globals to obtain speed, then a dispatch table might allow for reasonable maintanence:
my( $hrs, $mins, $secs, $day, $month, $year, ... ); my %res = ( qr[(\d\d):(\d\d):(\d\d)] => sub{($hrs,$mins,$secs) = ($1 +,$2,$3) }, qr[(\d\d)/(\d\d)/(\d\d(?:\d\d)*)] => sub{($day,$month,$year) = ($1 +,$2,$3) }, ..., '' => sub{ die "Unknown date format" }, }; ... $maybeTime =~ $_ and $res{ $_ }->() for keys %res;
|
|---|