Hello,
I am new to CGI and I am trying to do some web stuff and the one problem that I keep running into is figuring out the proper way to generate the html. For example I want to create some div elements like this:
<div id="div-test">
<div>Hello</div>
<div>GoodBye</div>
<div>Friend</div>
<div>Adios</div>
<div>Amigo</div>
</div>
My Perl code that generated the above:
my @fields = qw(Hello Goodbye Friend Adios Amigo);
print header,
start_html( -title => "testme"),
div (
{ -id => "div-test" },
# instead of doing this, can i create a div just by loopin
+g
# through @fields
div("Hello"),
div("GoodBye"),
div("Friend"),
div("Adios"),
div("Amigo")
),
end_html;
As the Perl Doc suggested, I've been using CGI standard to create my html, but I am not completely familiar with how to use it. I want to insert a foreach loop after my initial div to create a set of divs for each element in the array @fields. But when I do this, it throws a syntax error. I also noticed that I just can't insert a if statement or other Perl operations in a html declaration. How do I do this? If anyone can help, it would be great. Thank you for your time.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.