in reply to Loading $_ as checkbox value when $_ has double quotes in its value

s/"/&quot;/g; s/'/&apos;/g; print qq|<input type="checkbox" name="box$post_number" value="$_">|;

This works for both double as well as single quotes.

update: Err, no. It will render normally. Since &apos; and &quot; are simply entities browsers should render (as form values and as text), so dws' example where he assigns $_ to another variable isn't necessary at all.

[ ar0n -- want job (boston) ]

  • Comment on (ar0n) Re: Loading $_ as checkbox value when $_ has double quotes in its value
  • Download Code

Replies are listed 'Best First'.
Re: (ar0n) Re: Loading $_ as checkbox value when $_ has double quotes in its value
by jerrygarciuh (Curate) on Dec 04, 2001 at 11:29 UTC
    ar0n,
    Won't doing it that way screw the HTML? I mean it escapes the quotes around the font face for instance, no? Jeez it is too late for rational thought, I'll try it in the morning. Thx!
    jg
    _____________________________________________________
    If it gets a little bit out of hand sometimes, don't let it fool you into thinkin' you don't care.TvZ
      Won't doing it that way screw the HTML?

      In that case don't make $_ do double-duty. Instead, try

      my $dequoted = $_; $dequoted =~ s/"/&quot;/g; print qq|<input type="checkbox" name="box$post_number" value="$dequote +d">|;

        Don't quote your output at all print "stuff";

        Use a here document instead then you can put anything you fancy in it.

        print <<HTML; Delete This Post? \n <input type=checkbox name="box$post_number" value=" $_ "<p +> $_<hr>\n<p>\n<br><br><br>\n|; HTML