Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: SOAP::Lite - Finding callers IP

by foxops (Monk)
on Jan 23, 2003 at 14:36 UTC ( #229319=note: print w/replies, xml ) Need Help??

in reply to SOAP::Lite - Finding callers IP

How 'bout some inspiration.
Please forgive all the forward slashing, I've got a hacked-up version of Perl <shrug>
#!c:/Perl/bin/Perl.exe ## ## printenv -- demo CGI program which just prints its environment ## print "Content-type: text/plain\n\n"; print "\<HTML\>\n"; print "\<HEAD\>\n"; print " \<TITLE\>Testies, Testies, 1-2-3\<\/TITLE\>\n"; print "\<\/HEAD\>\n"; print "\<BODY BGCOLOR\=\"\#c0c0c0\" TEXT\=\"\#000000\" LINK\=\"\#ff000 +0\" VLINK\=\"\#0F0000\"\>\n"; foreach $var (sort(keys(%ENV))) { $val = $ENV{$var}; $val =~ s|\n|\\n|g; $val =~ s|"|\\"|g; print "${var}=\"${val}\"\n"; } print "\<\/BODY\>\<\/HTML\>\n";

Update:foxops shakes fist at Pardus

Replies are listed 'Best First'.
(jeffa) Re: SOAP::Lite - Finding callers IP
by jeffa (Bishop) on Jan 23, 2003 at 14:54 UTC
    Ugghh! Printing HTML like that, while good at getting stuff done farily quickly, is not recommended for those who wish to learn and grow. How about this instead:
    use strict; use warnings; use CGI qw(:standard); print header, start_html( -title => 'Testing 1-2-3', -bgcolor => '#c0c0c0', ), ul(li[map qq|$_ => "$ENV{$_}"|,keys %ENV]), end_html, ;
    Or this:
    use strict; use warnings; use CGI qw(header); use HTML::Template; my $tmpl = HTML::Template->new(filehandle => \*DATA); $tmpl->param(env => [ map {{ key => $_, val => $ENV{$_}, }} keys %ENV ]); print header, $tmpl->output; __DATA__ <html> <head> <title>Testing 1-2-3</title> </head> <body bgcolor="#c0c0c0"> <ul> <tmpl_loop env> <li><tmpl_var key> = "<tmpl_var name="val" escape="HTML">" </tmpl_loop> </ul> </body> </html>
    And ... if you still insist on printing out HTML like you did, then at least check out the q and qq operators:
    # look ma, no slashes! print qq|${var} = "${val}"\n|; print q|<body bgcolor="#c0c0c0">\n|;


    (the triplet paradiddle with high-hat)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://229319]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2017-08-18 02:18 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (294 votes). Check out past polls.