Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Print Flat File to HTML

by naikonta (Curate)
on Nov 20, 2007 at 06:51 UTC ( #651871=note: print w/ replies, xml ) Need Help??


in reply to Print Flat File to HTML

The default filehandle is STDOUT so to print to other filehandle you have to explicitly specify it. But you can avoid to express the filehandle if you select it before printing. Always check your open statement.

open OUTFILE, ">result.html" or die "Can't write to result.html: $!\n" +; select OUTFILE; print "<html><head>"; print "other html stuff";
You can save the print statement with the here-document style.
print <<HTML; <html><head> <title>HTML with here-docs</title> ... ... more stuff HTML # do some processing for my $item (@items_from_somewhere) { print "<li>$item\n"; } print <<HTML ... continue HTML ... </body></html> HTML
But, I think you can get the most from templating system such as HTML::Template. I do.

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


Comment on Re: Print Flat File to HTML
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://651871]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (17)
As of 2014-07-11 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls