in reply to Trouble Getting Local Variable $_ to return reformatted string

minor nits, OT of your now-solved chief question:
First..

...because the nasty characters my customers insist on typing into their descriptions occasionally makes the HTML page break.
For example, I want to exchange a tick mark (') with (& rsquo ;) ...

You're on the money in saying "customers" sometimes insert "nasty characters." They certainly can and do and sometimes that will bork stuff... but I don't know any way a simple tick could, in your word "break" the HTML page; an ASCII "'" does NOT (in my experience) cause any issue with a browser's rendering. Perhaps this is merely incautious phrasing, but if not, I'd be interested in an example to clarify my understanding.

and, second... When posting two distinct bits of code, it would be well to enclose them in individual sets of <c>...</c> tags,

Welcome to the Monastery! Perhaps the promptitude of the excellent replies above will prompt you to get a login.

  • Comment on Re: Trouble Getting Local Variable $_ to return reformatted string

Replies are listed 'Best First'.
Re^2: Trouble Getting Local Variable $_ to return reformatted string
by jhourcle (Prior) on Jun 18, 2007 at 15:49 UTC
    They certainly can and do and sometimes that will bork stuff... but I don't know any way a simple tick could, in your word "break" the HTML page; an ASCII "'" does NOT (in my experience) cause any issue with a browser's rendering. Perhaps this is merely incautious phrasing, but if not, I'd be interested in an example to clarify my understanding.

    Attribute values inside an HTML element, when you're using the same type of quotes around the element in question:

    <img alt='Bob's Birthday Party' src='birthday.jpg' height='480' width='640'>

    You might have the same issue with double quotes, if you're double quoting the values of the attributes.

      You're right, of course and thank you. The apostrophe (as a straight tick) inside your single quoted alt would definitely be a problem.

      However, my "incautious phrasing" perhaps led you to this.

      I see no indication that OP was allowing customers insert anything inside .html elements, tags or values. (And -- aside -- he's fetching the data from a database, which might suggest the cleanup should occur before the customers are allowed to insert it there)

      So, rephrasing:

      ...a simple tick (in the kind of data context presented by the OP) could, in....

      And, again, thank you. That kind of good-catch may save much grief for some future reader presented with my ill-considered words
          ...and I surely hope this is more precise