Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

On a contrarian note, thetallblondguy, the time it has taken you to consider the partial solutions in this thread, and the different ways you could indicate variables, might have been better spent looking into a full-grown "real world" application like Template Toolkit (or any of the legion of its kin). Because if this is any kind of serious work, this is not the kind of wheel you want to re-invent.

Your clarification actually suggests your question is not really a perl or CGI question, but a question about how to *surgically* separate the Perl from HTML without breaking either one. That's exactly what templating systems are designed to do.

Sure, you could create perl subroutines that spit out HTML, or separate files with some (special syntax) in them, but the list of wheels you would have to re-invent to get it right are too numerous to list here. For example:

How to disambiguate 'true variables' from 'false variables'? $19.95USD -> not a variable, a price $e1p_zE@z -> not a variable, a suggested user-password Micro$oft -> not a variable, a common company name $$$CASH$$$ -> not a variable, a common spam subject line How to handle common scenarios that always come up? # A variable whose value is contingent on another variable # A variable that appears inside of a loop # A variable that should have some 'default' fill in value if the user +-supplied value is left blank # A sample code-snippet that should appear inside the HTML and not be +messed with or interpolated AT ALL

There is a whole catalogue of issues to deal with, and each issue you resolve (on your own) means yet one more (undocumented) 're-invented wheel' that the person who comes after you will have to learn just to figure out what is going on.

If you *really* insist on creating your own system from scratch, you should at least try to use a totally unique syntax for indicating the presence of a 'true variable' ... something that is not likely to appear in any other context.

Hello @@@:username:@@@, Please consider using @@@:existing_template_system:@@@ instead of creating your own from scratch; instead of hand-rolling the @@@:huge_number:@@@th ad-hoc system that no one understands except you.
=oQDlNWYsBHI5JXZ2VGIulGIlJXYgQkUPxEIlhGdgY2bgMXZ5VGIlhGV

In reply to Re: inserting HTML file in a PERL script by dimar
in thread inserting HTML file in a PERL script by thetallblondguy

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 sharing their wisdom with the Monastery: (5)
As of 2024-04-19 13:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found