in reply to Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts
in thread LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts

Your update added an implementation for one escapeHTML which is completely redundant with the one (even named the name!) provided by CGI.pm!

Simply change your calls to escapeHTML with CGI::escapeHTML, or import it with use CGI qw(escapeHTML), then remove the entire last half of your program, and you're done!

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts

Replies are listed 'Best First'.
Re: Re: Re: LWP::UserAgent; HTTP::Headers; HTTP::Request; CGI; automated scripts
by tachyon (Chancellor) on Sep 24, 2001 at 20:13 UTC

    As you state an escapeHTML routine is provided by CGI.pm. For the purpose which is intended (ie display plain text in a browser window in the original form) CGI.pm's routine is inadequate.

    I make this red flag to bull statement because it does not actually escape text in such a way as to render text with multiple spaces or newlines in a form that imitates the original text. Any sequences of spaces will render as a single space if you use $q->escapeHTML(). The snippet presented does the required &nbsp; subs. It offers the opportunity to convert \n to its HTML equivalent of <BR> which is potentially required. It also adds Perl Monks posting comptibility by escaping the [ and ] which thus far seems to have strangely been overlooked in CGI.pm :-)

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Then wrap that result in a <pre>...</pre> block. That'd be more appropriate anyway, since the params are likely to be "characters of interest" rather than "text".

      And by the time you've done all that, you're back to realizing that you really didn't want an HTML result in the first place, and you're back to my program which is tons simpler.

      -- Randal L. Schwartz, Perl hacker

        The Answer is 42

        But can even remeber what the original question was?