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

That script fails to properly escape environment variables that contain HTML-sensitive characters, a common mistake of course. I'd stick with something this simple:
#!/bin/sh echo content-type: text/plain echo printenv
Yeah, and if you're not on a system with a shell or printenv, you can do it in Perl if you insist:
#!/usr/bin/perl print "Content-type: text/plain\n\n"; print "$_\t$ENV{$_}\n" for sort keys %ENV;
See how much simpler that is? And no problems if there's HTML involved.

Sometimes, HTML is overkill.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Dumping the CGI environment
by tachyon (Chancellor) on Sep 24, 2001 at 06:38 UTC

    You are of course correct that I should have escaped the env variables for HTML display so I have added a sub and a credit. You will of course have to view source to get useful output from your example as it will be solidly uninteligible in a browser window where it will appear as one long string. It is short and sweet though :-)

    cheers

    tachyon

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

        Oh the humilitation. Fell for the old you see what you expect when reading code problem. I misread it as "text/html". Back to the grindstone of humble mediocrity.

        cheers

        tachyon

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