Hi Kurt,

You can save yourself the if statement. If the pattern is not found the 
s/// will not proceed. That will save process ting the line twice when you 
do match the pattern.

Other than that, you are changing "nl" followed by a single letter to <pX>" 
with  X being a digit corresponding to that letter.

Why not put those into a hash?

$sub("i" => "", "t" => 1, "h" => 2, "p" =>3);

You can also buntch your /,[,< into [] which will save you those ors, which 
make things much slower

s:[/\[<]ni(\w)[/\]>]:<p$sub{$1}>:g;




R

At 05:30 08/10/2002 -0500, Faymon, Kurt wrote:
>Give a 'config file' with 100 or so entries of global subs like:
>
>"/nli/|[nli]|<nli>","<p>"
>"/nlt/|[nlt]|<nlt>","<p1>"
>"/nlp/|[nlp]|<nlp>","<p3>"
>"/nlh/|[nlh]|<nlh>","<p2>"
>And so on...
>
>I read these into a hash (sPiChars) with 'replace' value as key and the
>RegEx of the search terms as value of that give key. Then as I go over
>process each record in input, I check to see if one of these values present
>and then sub it if so, like:
>
>foreach $key(keys(%sPiChars))
>                 {
>                 if($sTempRecord=~m/$sPiChars{$key}/)
>                         {
>                         $sTempRecord=~s/$sPiChars{$key}/$key/g;
>                         }
>                 }
>
>Which works, but it really kinda slows things down. Willing to admit that
>it's a small miracle I even got this to work, I'm guessing there is a better
>way to deal with many subs with RegEx; any clued as to which paths I should
>wander down in terms of increasing the efficiency of this?
>
>Thanks - kf
>[EMAIL PROTECTED]
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to