[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] Q on Substitution improvement



Actually, I handle & after the foreach on %easySubstitutions, in this
block:

	#This one has to come first, so it doesn't undo all the others...
	unshift @subs,  sub{ ${$_[0]}=~s/&/&/g;};

The & substitution has to be done first, so that it doesn't transform
things like < to <

Your solution was more concise (of course :); but I wonder if mine would be
faster, since the regexes only
get compiled once each at sub construction time?  Or would the sub call
overhead swamp that?  I wish I had time
to benchmark that this morning...
-- 
Mike

> -----Original Message-----
> From:	merlyn@stonehenge.com [SMTP:merlyn@stonehenge.com]
> Sent:	Tuesday, June 22, 1999 19:49
> To:	Mike Giroux
> Cc:	Walter Torres; fwp@technofile.org
> Subject:	Re: [FWP] Q on Substitution improvement
> 
> >>>>> "Mike" == Mike Giroux <rmgiroux@jemmcop.com> writes:
> 
> Mike> 	# One entry per "easy" substitution
> Mike> 	my %easySubstitutions=( '>' => '&gt;',
> Mike> 				'<' => '&lt;',
> Mike> 				'"' => '&quot;');
> 
> You forgot & => &amp;
> 
> -- 
> Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
> Keywords: Perl training, UNIX[tm] consulting, video production, skiing,
> flying
> Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger
> merlyn@teleport.com)
> Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
> Quote: "I'm telling you, if I could have five lines in my .sig, I would!"
> -- me

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org