Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bespoke HTML, CSS, JavaScript with CGI 4

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I've been using PERL for many years and write all my HTML code by hand using a zillion backslashes.

On a few of my posts people have said "Why are you writing HTML, use the CGI module, you'll never have to write a line of HTML code again"

one claimed they write all theire CSS menu's, forms, webpages etc.. with the PERL CGI module.

can someone explain to me how, how can the CGI module know how to draw your menu, without you using HTML, this doesn't make any sense to me.

Can anyone help explain how all this is done with the CGI module without writing a single line of HTML?

Thanks 1DMF



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Hi

1DMF said:
this doesn't make any sense to me.
[ignore][flame][/ignore]
Neighter to me. If you learn to use CGI.pm, you will know CGI.pm. Then if you will need to pass forward and use something else instead of CGI.pm, you will realize that your knowledge does not help you anymore. I prefer to learn HTML and to write my documents "by hand". That is the real usefull knowledge.

Beside this I tried some CGI.pm's possibilities and did not like them. Makes debuging much difficult and the code obscure. At least for me.

Sorry for flaming.
[/flame]

Feherke.
 
I fully agree with you :)

i still don't understand how you can create DHTML pages utilising CSS, HTML and JavaScript, just by using a PERL module.

how's it know what code to write on my behalf just by calling a method on an object?

if they mean i'm stuck to having the menu in-built with CGI and cannot use my own , then i'm not interested, my menu, my code, my choice!

as you say it's always good to have experience of as many languages as possible.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
You're still using HTML, just using cgi.pm to put the tags in rather than writing them longhand. so instead of this:
Code:
print "<p>Hello World</p>";
You can do this:
Code:
print p("Hello World");
Of course once you start nesting elements inside eachother, in a table for example, it all gets pretty hairy. It's all described at
Like previous posters, I prefer to print my own tags out.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
oh I just had a quick browse through the documentation, man that is UGLY!!!

I'd rather wade through a zillion backslashes than use that syntax, why re-invent the wheel, if you know HTML/DHTML/XHTML why bother?

what would you rather use
Code:
print $q->start_html(-title=>'The Riddle of the Sphinx',
        -script=>[
                  { -language => 'JavaScript1.0',
                    -src => '/javascript/utilities10.js'
                                    }
                  ]);
or
Code:
<!-- Comment about script -->
<script language=\"JavaScript\" src=\"[URL unfurl="true"]http://www.mydomain.com/scripts/myscript.js\"></script>[/URL]
or you could write the script direct to browser without using an external link file.

I love PERL, but I don't think i'll use CGI, although the security in dealing with forms & post data i keep being told is worth a look. I also found I couldn't get my own code for file uploads to work for large music files, i solved the problem by using the CGI module to parse the enctype data.

So i'm not dismissing CGI, just the HTML bit of it :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
well, you don't have to use escapes either, use the 'qq' operator (for strings with variable interpolation) to print/construct your strings or 'q' if there is no variable interpolation needed:

print q~<!-- Comment about script -->
<script language="JavaScript" src="~;

but if you like typing \ for no good reason that's cool. [wink]

Admittedly, using CGI.pm to construct complicated html (if there really is such a thing) takes getting used to. There is also a bit of an elitist attitude (which is a very unperlish attitude to have IMHO) when people say they never use raw html in their perl scripts, as if writing html code is below their dignity. But everyone has their prefered methods, and if they prefer to keep function and form seperate (similar to what CSS does for HTML) I can understand that. There could be a very good reason for doing so. If they prefer to write all html code by hand into their scripts I can understand that too. I see no reason to take sides on this (non)issue what-so-ever.
 
Agreed on the sides thing, of the non issue.

The benefit of using CGI.pm IMO is that when writing headers, or the like, let CGI.pm do it, because if, or when, there's a change to headers, all you have to do is upgrade CGI.pm, not your sources ...

Tables in CGI.pm can look incredibly messy, but if you're using DIV's for layout, which is much better for markup and SEO, then this too becomes a non issue.

just my €0.02

--Paul

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Because CGI.pm produces correct headers for application types, javascript, HTTP headers ... I don't need to handroll my headers, or edit them by visiting each source in succession, or writing a script to do inline editing, just update CGI.pm, and job done ...

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
print "Content-Type: text/html\n\n";

is a source of many problems on this and other perl boards

$q=new CGI;
print $q->header();

Job solved ...

Make sense now?

Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
you know the funny thing, I still can't remember the full syntax for
Code:
Content-Type: text/html\n\n
and keep referring back to another script to copy it from.

So to be honest
Code:
$q=new CGI;
print $q->header();
isn't any easier to remember.

The important thing to remember is your gonna need one or the other!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
wow - have you written a novel, that's got to be the most characters i've seen on a web page. Am I meant to read it :p

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
why, and what's the difference, why can't both know both?

What defines a webmaster, at what point do they cross over to a programmer, do you not concider HTML a programing language?

what happens when you throw JavaScript into the mix?

this gets so confusing

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Hi

1DMF said:
do you not concider HTML a programing language?
No, HTML is a markup language, suitable to write documents in it, not programs. I hope this makes clear the difference between the webmaster and web programmer. ( Or at least, my point of view, regarding the difference. )

Feherke.
 
so Markup is not concidered a programing language because it is purely for formatting output and cannot change the output, is that your train of thought.

i consider a programing language anything that needs to be coded. Plus it still needs to be interpreted.

Although granted it has its limitations. But since the advent of DHTML i think it criss-crosses across many attributes needed by an individual to acheive a goal.

Designer, Developer, Web Master, Support, Programmer.

To truely succeed on the web we all have to wear many hats, for various roles.

You know I didn't realise all a web master did was implement HTML, wow that job must be boring.





"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top