my %cache; sub _iso8601_rx { my($self,$rx) = @_; my $dmt = $$self{'tz'}; my $dmb = $$dmt{'base'}; return $cache{ $rx } if exists $cache{ $rx }; } $cache{cdate} = '(?\d\d\d\d)-(?\d\d)-(?\d\d)'; $cache{ctime} = '(?\d\d):(?\d\d):(?\d\d)'; $cache{fulldate} = "$cache{cdate}\\s+$cache{ctime}"; 1; #### my %cache; sub _iso8601_rx { my($self,$rx) = @_; my $dmt = $$self{'tz'}; my $dmb = $$dmt{'base'}; return $cache{ $rx } if exists $cache{ $rx }; } $cache{cdate} = <<'ERX'; (?i-xsm:(?:(?\d\d\d\d)(?\d\d)(?\d\d)|(?\d\d\d\d)\-(?\d\d)\-(?\d\d)|\-(?\d\d)(?\d\d)(?\d\d)|\-(?\d\d)\-(?\d\d)\-(?\d\d)|\-?(?\d\d)(?\d\d)(?\d\d)|\-?(?\d\d)\-(?\d\d)\-(?\d\d)|\-\-(?\d\d)\-?(?\d\d)|\-\-\-(?\d\d)|(?\d\d\d\d)\-?(?\d\d\d)|\-?(?\d\d)\-?(?\d\d\d)|\-(?\d\d\d)|(?\d\d\d\d)W(?\d\d)(?\d)|(?\d\d\d\d)\-W(?\d\d)\-(?\d)|\-?(?\d\d)W(?\d\d)(?\d)|\-?(?\d\d)\-W(?\d\d)\-(?\d)|\-?(?\d)W(?\d\d)(?\d)|\-?(?\d)\-W(?\d\d)\-(?\d)|\-W(?\d\d)\-?(?\d)|\-W\-(?\d)|\-\-\-(?\d))) ERX $cache{ctime} = <<'ERX'; (?-xism:(?:(?[0-1][0-9]|2[0-3])(?[0-5][0-9])(?[0-5][0-9])(?:[\.,]\d*)?|(?[0-1][0-9]|2[0-3]):(?[0-5][0-9]):(? ... bulk of the regex ellided because PM won;t let me post that much! ... azt|ret|mot|gyt|lrt|ut|e|a|u|k|o|d|z|t|n|p|y|g|w|s|c|i|m|b|q|v|r|x|h|f|l)) \))? ))))?) ERX $cache{fulldate} = <<'ERX'; (?x-ism:^\s*(?: (?i-xsm:(?:(?\d\d\d\d)(?\d\d)(?\d\d)|(?\d\d\d\d)\-(?\d\d)\-(?\d\d)|\-(?\d\d)(?\d\d)(?\d\d)|\-(?\d\d)\-(?\d\d)\-(?\d\d)|\-?(?\d\d)(?\d\d)(?\d\d)|\-?(?\d\d)\-(?\d\d)\-(?\d\d)|\-\-(?\d ... bulk of the regex ellided because PM won't let me post that much in a single post! ... nmt|lkt|gst|vet|tjt|eat|ept|cat|pht|pwt|nft|set|gft|hst|nut|qmt|mpt|trt|ywt|cdt|emt|met|ast|net|kst|ect|brt|bdt|mvt|cst|cvt|fmt|azt|ret|mot|gyt|lrt|ut|e|a|u|k|o|d|z|t|n|p|y|g|w|s|c|i|m|b|q|v|r|x|h|f|l)) \))? ))))?) | (?-xism:(?:(?[0-1][0-9]|2[0-3])|\-(?[0-5][0-9]))) )\s*$) ERX 1; #### #! perl use strict; my %cache = ( ctime => <<'RXA', cdtate => <<'RXB', fulldate -> <<'RXC' ); ##... monster regex initialisation ellided; my $refull = qr[$cache{ fulldate }]x; my $rectime = qr[$cache{ ctime }]x; my $recdate = qr[$cache{ cdate }]x; for (1..100e6) { "2010-02-01 01:02:03" =~ $refull; "2010-02-01 01:02:03" =~ $rectime; "2010-02-01 01:02:03" =~ $recdate; }