Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^3: View The HTML ???

by Aristotle (Chancellor)
on Aug 26, 2003 at 02:52 UTC ( [id://286566]=note: print w/replies, xml ) Need Help??

in reply to Re: Re: View The HTML ???
in thread View The HTML ???

Update: I'm a klutz.. don't forget to see asarih's reply below.

FWIW, you need to add s/&/&/g; to your substitutions for a minimal escaping solution.

Also, you must terminate your entities with a semicolon - it's < and not &lt. (Well, the latter is acceptable in some cases under SGML, but don't go there unless you like headaches.)

A few style suggestions on your code - try something like this:

s/</&lt;/ for @HTML; s/>/&gt;/ for @HTML; s/&/&amp;/ for @HTML; print '<textarea>', join("", @HTML), '</textarea>';
Much easier on the eyes, no? Anyway, as I've already said:
use CGI qw(:standard); print textarea('', escapeHTML(join '', @HTML));

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^3: View The HTML ???
by asarih (Hermit) on Aug 26, 2003 at 02:58 UTC
    If you don't want to use, don't forget /g regex modifier, and remember to substitute the ampersands first, then angle brackets.
Re: Re^3: View The HTML ???
by halley (Prior) on Aug 26, 2003 at 16:18 UTC
    If you're not going to use the CGI or other already-invented wheels, do make sure you get your ordering right, or you'll end up with &amp;lt;BR&amp;gt;&amp;nbsp; all over the place.
    for (@HTML) { s/&/&amp;/g; s/</&lt;/g; s/>/&gt;/g; }

    If you really wanted to use the map method, you don't need intermediate variables for each possible step. @finished = map { ... } map { ... } map { ... } @originals works just fine. (The last mentioned map is performed first.)

    [ e d @ h a l l e y . c c ]

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://286566]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-06-16 09:36 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.