Hi Josh, I took your advice about the optimization and now have the following: (It *is* tested and works).
#============================================================= sub HTMLDecode { my $self = shift if scalar(@_) > 1; my $str = shift; $str =~ s/&#(\d+);/chr($1)/eg; return $str; }# end htmlDecode() #============================================================= sub HTMLEncode { my $self = shift if scalar(@_) > 1; my $str = shift; return '' unless defined $str; my $toEncode = ref($str) ? $str : \$str; $$toEncode =~ s/( [^A-Z a-z 0-9 [EMAIL PROTECTED]&\*\(\)\-_\+\=\{\}\[\]\:;'"\<,\>\.\?\\\s\/])/ "&#" . ord($1) . ";"/egsx; if( ref($str) ){ return $toEncode }else{ return $$toEncode }; }# end htmlEncode() _______________________________________________________________ John Drago | Chief Architect of Software Development E-com Media Group, Inc. [www.e-commedia.com] office :: 303.790.7940 x25 email :: [EMAIL PROTECTED] E - b u s i n e s s w i t h D i m e n s i o n TM | -----Original Message----- | From: Josh Chamas [mailto:[EMAIL PROTECTED] | Sent: Tuesday, March 02, 2004 6:01 PM | To: John Drago | Cc: [EMAIL PROTECTED] | Subject: Re: HTMLEn/Decode replacements | | John Drago wrote: | > Hello, | > | > I needed to make some changes to the Apache::ASP::Server::HTMLEn/Decode | > subroutines so they would suit a particular purpose in a project I am | > working on. | > | > I am putting this code out here for what it's worth. These work as | > drop-in replacements for the subroutines by the same name in | > Apache::ASP::Server.pm | > | | Hi John, | | In considering adding this to the Apache::ASP code, I am wondering | under what circumstances you would want to do this? For possible | inclusion, | this might be something like HTMLEncodeEntities() or some such... | | Also, if it does not make it in, you might consider subclassing | Apache::ASP::Server, | so you do not have to modify the base class itself. As an optimization | for | large conversions, you might lose the while() and: | | # not tested! | $$toEncode =~ s/[EMAIL PROTECTED]&\*\(\)\- | _\+\=\{\}\[\]\:;'"\<,\>\.\?\\\/\s]/"&#" . ord($char) . ";"/egs; | | Regards, | | Josh | | ________________________________________________________________________ | Josh Chamas, Founder | NodeWorks - http://www.nodeworks.com | Chamas Enterprises Inc. | NodeWorks Directory - http://dir.nodeworks.com | http://www.chamas.com | Apache::ASP - http://www.apache-asp.org | | | | --------------------------------------------------------------------- | 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]