Yea right now I just have a whole list of filters
@HTMLUN2 = map { s/</</; $_ } @HTMLUN1;
@HTML = map { s/>/>/; $_ } @HTMLUN2;
print <<HTML;
<textarea>@{[join("",@HTML)]}</textarea>
HTML
I am looking for the command that does all the stuff for me, so i don't need to map { everything. | [reply] [Watch: Dir/Any] [d/l] [select] |
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 <. (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/</</ for @HTML;
s/>/>/ for @HTML;
s/&/&/ 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. | [reply] [Watch: Dir/Any] [d/l] [select] |
If you don't want to use CGI.pm, don't forget /g regex modifier, and remember to substitute the ampersands first, then angle brackets.
| [reply] [Watch: Dir/Any] [d/l] |
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 &lt;BR&gt;&nbsp; all over the place.
for (@HTML) {
s/&/&/g;
s/</</g;
s/>/>/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 ] | [reply] [Watch: Dir/Any] [d/l] [select] |