Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, Perl Monks,
I am a noob to the programming of Perl, i have done some practices of Perl but it is still difficult. For example, i am trying to use Perl to write Html, where basically i write a few paragraphs using notepad and then cat it with a Perl program and then it would produce a desired html file of the few paragraphs. the code i have at this point looks like this:
#!usr/local/bin/perl $pattern = "title:"; while (line = <>){ if ($line =~ /$pattern/){ ($garbage, $myTitle) = split(/:/, $line, 2); print "<Html> <Title>$myTitle</Title>"; } } print "<body>" $pattern = "subtitle:"; while (line = <>){ if ($line =~ /$pattern/){ ($garbage, $myParagraph) = split(/:/, $line, 2); print "<body>$my Paragraph" } if (eof) { print "</body>" } } print "</html>"
Since i am not very good at html or perl, i would like to listen to some suggestions for the code from my monk brethrens. An example of a few paragraph to be put on the html may be in the following format: (taking just a few sample quotes from above forum topics)
Title:My Page Subtitle:When somebody buys an item on the list (from a real shop - no +thing to do with the website) they can go onto the site, and change t +he value of that item from "Not bought" to "Bought by person 2" for i +nstance, then click SUBMIT and the HTML will then permanently reflect + the changes so that the item will always have "Bought by person 2" n +ext to it - therefore preventing multiple purchases from other family + members! Does that make sense? I hope so. I know HTML really well, and know how + to install CGI scripts and stuff - It's just writing them which prov +es tricky! Subtitle: Hello great monks. Can someone tell me how to keep perl dbi +silent when something goes wrong? ie.....I do a table cleanup before +I start importing my data. Basically, I just delete what temp tables +are there. If my script crashed on a previous run, it leaves some tem +p tables behind. I need to clear those tables before I can import dat +a. In php, I leave off the "or die()" statement and php doesn't fuss +if those tables are not there. But with perl dbi, it fusses if the ta +bles are missing even with the DIE command missing.
Other than that it can be also helpful if you guys can point out some hints on how to do bold italic or different sized html words using Perl. Thanks once more my Perl Brethrens!
20031125 Edit by Corion: Added formatting (hopefully correct)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using Perl to make Html file
by dragonchild (Archbishop) on Nov 25, 2003 at 20:19 UTC | |
|
Re: Using Perl to make Html file
by davido (Cardinal) on Nov 26, 2003 at 00:28 UTC | |
|
Re: Using Perl to make Html file
by husker (Chaplain) on Nov 25, 2003 at 21:36 UTC |