putting everything in that one regexp made everything much faster. However theres one anomaly that i don't quite understand. I played a little with the options at the end of the regexp, mainly "g" and "i".sub adj3_gi { my $path='\\'; my $computer = "LAIN"; foreach(@_) { # skip if it doesn't start with either a space or backslash, or if + it starts with " ." or " .." next if ((/^[^ \\]/) || (/^ {2}\.{1,2}\s/)); # process path if first char is '\' if (/^\\/) { chop; $path = "$_\\"; } # break apart returned directory and file info elsif (/^ {2}(.*?(\.([^\.]+?))?) {5} *([HDRSA]*) +(\d+) {2}(.*)/gi +`) { #print "{$computer\:$path$1, ". (defined $3 ? $3 : "").", $4, +$5, $6 }\n"; } } }
I ran this several times, and the results were all similar. Now i could *possibly* understand the g making things faster. but the i? i was always under the impression (from both professors and fellow coders) that the /i would make things slower. Noone i asked can explain it. Or is this more regexp voodoo? ^_^with g: 4 wallclock secs ( 3.91 usr + 0.00 sys = 3.91 CPU) with gi: 4 wallclock secs ( 3.64 usr + 0.00 sys = 3.64 CPU) with i: 7 wallclock secs ( 6.40 usr + 0.01 sys = 6.41 CPU) with none: 6 wallclock secs ( 6.77 usr + 0.00 sys = 6.77 CPU)
In reply to Re: Re: Happy fun regexping
by cyberconte
in thread Help needed with reducing function to a single regex
by cyberconte
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |