On Jul 27, Paul Tremblay said: >The only problem is how I should replace "&", ">", and "<". I think I'll >do single line subs for this text. Even with huge files it shouldn't >take more than 1/2 a second or so, and that allows me to use your >original method to speed things up. > >Or this just occurred to me: > >s[(&)|(<)|(>)|\\($rx)][<$rep{$1}/>]go; > >Yea, that should work!
No, $1 is either "&" or undef. Perhaps you want: s[([&<>])|\\($rx)][<$rep{$+}/>]go; That $+ means "the last () that matched". But that still replaces & with <&/>. So you'd need to make the '<' and '/>' part of the %rep hash's values. I would suggest: s[([&<>])|\\($rx)][$1 ? $rep{$1} : "<$rep{$2}/>"]ego; Then, $rep{'&'} can be '&', and it won't translate to "<&/>" but only "&". But the /e modifier might slow things down too much. Therefore, perhaps a separate s///: s[([&<>])][$simple{$1}]go; s[\\($rx)\s+][<$complex{$1}/>]go; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]