Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Escaping special characters for HTMLby serf (Chaplain) |
on Jan 04, 2006 at 16:14 UTC ( [id://520948]=note: print w/replies, xml ) | Need Help?? |
Where you are needing to nest double quotes I would recommend using
or similar notation where the double quotes are for Perl and not part of the data - and save the normal " double quotes for where they *need* to be used in the HTML/JavaScript/CSS. It will make it much easier to tell where the quotes need to be, and you will be able to have double quotes in your data without escaping them. You are also using more concatination operators than you need to (which doesn't make your code any faster!) e.g. where you have: You could use: i.e. protecting the scalar names with {} where they have to be followed immediately by more plain text or underscores. This will improve readability because it will make the code look more like the output is going to look and make the Perl scalars stand out a bit within the code. NB: you don't *need* to do this when the scalar is followed by an ampersand or other non-variable name character (beware of [ or { which would be the start of an array index or hash though!) It could also simplify things if you did your maths before the assignment instead of embedding it into the concatination if you don't need it to change while it's in the concatination (especially as you're doing the same maths more than once): could become: the only bit that looks particularly broken is the -onmouseover => '...' - it has two 'return's in it for starters... and I'm not sure what else wrong with it, but apart from that I get:
In Section
Seekers of Perl Wisdom
|
|