Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Net::Whois::Raw qw( whois );

by k0rn (Acolyte)
on Apr 21, 2009 at 00:40 UTC ( [id://758839]=perlquestion: print w/replies, xml ) Need Help??

k0rn has asked for the wisdom of the Perl Monks concerning the following question:

When useing Net::Whois::Raw qw( whois ); The results come out on one big long line. This is not ideal. How can I change this.
#!/usr/bin/perl # Whois script use CGI qw(:standard escapeHTML); use Net::Whois::Raw qw( whois ); # Get values from form my $domain = param('domain'); # Check for blanks unless (param('domain')){noname('a domain')}; #Get whois information $whois = whois($domain); #Print whois information print "Content-type: text/html\n\n"; HEADER('Results'); print <<EOT; $whois EOT FOOTER(); exit; # We stop here # Header subroutine sub HEADER { my($title) = @_; print <<EOT; <HTML> <HEAD> <TITLE>$title</TITLE> </HEAD> <body bgcolor="#263C6D" text="white" link="#ffffff" vlink="#C0C0C0" al +ink="#C0C0C0"> EOT } # Noname Subroutine sub noname { my($reason) = $_[0]; print "Content-type: text/html\n\n"; HEADER('Blank Entry'); print <<EOF; <H1><center>Incomplete</H1></center> <center>Please fill in all required fields. You are missing $reaso +n</center> EOF FOOTER(); exit; #we Stop Here } # Footer Subroutine sub FOOTER { print <<EOT; </BODY> </HTML> EOT }

Replies are listed 'Best First'.
Re: Net::Whois::Raw qw( whois );
by quester (Vicar) on Apr 21, 2009 at 01:26 UTC

    Normally HTML ignores newlines. There are (at least) two simple ways of including output from a Unix command.

    One is to enclose the output in <pre> and </pre>, so that

    newlines, like this one -->
    are not ignored.
    It also tells the browser to use a monospaced font,
    so that text in         columns
    will line up            correctly.
    

    On the other hand, you may decide that the monospaced text looks kind of ugly.

    The other way is to enclose each line in the HTML sequence <p> ... </p> like this (caution: not tested):

    $whois =~ s{^}{<p>}mg; $whois =~ s{$}{</p>}mg;

      replace the \n with <br/>

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://758839]
Approved by AnomalousMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-24 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found