Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Calling functions in middle of CGI HTML declarations by dr.jekyllandme

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found