Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: a Couple of questions!

by jonadab (Parson)
on Sep 20, 2003 at 15:00 UTC ( #292863=note: print w/replies, xml ) Need Help??


in reply to a Couple of questions!

which tool may i use to make beautiful perl cgi web pages and then insert perl code where i want too?

Perl or no Perl, if you want beautiful pages you'll write them by hand (possibly using an editor with helps, such as cperl-mode in Emacs). The automatic page generation tools (Dreamweaver, Frontpage, Composer, and their ilk) invariably produce very messy code, code that's not maintainable, code that's needlessly bloated, code that's impossible for a human to read if you need to look at it to debug a problem, code that relies so extensively on physical markup (e.g., font tags) that you must abandon all pretense of accessibility, code that won't validate in a billion years, code that relies so heavily on browser quirks that when the next versions of the major browsers come out it will probably break and you'll have to redo it all. The advantages of these tools mostly involve people who don't know very much HTML being able to whip up a bunch of pages quickly. There's nothing beautiful about the results.

My advice if you want to make beautiful pages is to read one of the w3schools tutorials, which will take you all of an hour, get a text editor with good syntax highlighting and automatic indentation, and write the pages by hand. Bonus points if your editor will automatically insert the close tag together with the open tag; this helps greatly in keeping your code wellformed. Oh, and a graphic design course won't hurt, too.

As far as inserting the Perl code, there are two ways to go. You can use embperl, or you can make the whole page a Perl script, sticking the HTML in strings or HERE documents that the script prints. The latter approach is the one I use.

update: Templates are on my list of things I intend to evaluate; my recommendation should not be taken as advice against using templates.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Replies are listed 'Best First'.
2Re: a Couple of questions!
by jeffa (Bishop) on Sep 20, 2003 at 15:46 UTC

    Great advice, but i have a couple of nitpicks:

    I start off with Dreamweaver ... but i don't maintain with Dreamweaver. Big difference. The advantage here has nothing to do with how much knowledge of HTML i have, but instead how much drudgery i don't want to type myself. Making a table is so much easier with the mouse, and the resulting HTML can always be filtered through HTML Tidy if i don't like it.

    You forgot to mention a third way: seperate your Perl code from the HTML. This is where HTML::Template and Template rule. I no longer use those gruffy looking HERE docs for HTML.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      Making a table is so much easier with the mouse

      With a decent editor1, this is simply not true. A few lines of lisp in your configuration go a *long* way toward reducing the amount of typing you have to do. In cperl-mode (with my custom enhancements in the hook), I hit one keystroke for my insert-tag function, type in table, hit Enter, and the following is inserted:

      <table width=\"100%\"><thead> <tr><th></th></tr> </thead><tbody> <tr><td></td></tr> </tbody></table>
      And it leaves my cursor positioned inside the th. Similar shortcuts exist for other common tasks. My fingers never have to leave the keyboard.


      1 -- By <q>a decent editor</q> I of course mean Emacs, but this is not intended to start an editor war; feel free to customise your editor of choice in a similar fashion, if it provides the facilities for you to do so.

      $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

        I think we are comparing apples and oranges here ... I recently designed a web site that used some pretty complex table arrangements for the layout of certain 'widgets'. I used Macromedia Fireworks to design the graphic first, then i "sliced" the graphic into pieces, keeping some elements as graphics while replacing others with modifiable text.

        Emacs may be a nice editor, but it won't do that, as it really only deals with text. If i have time, i can recreate an example, but can't show you the one i made ... contract. :(

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
      what exaclty is a template and how can i use it?
Re: Re: a Couple of questions!
by Nik (Initiate) on Sep 20, 2003 at 15:07 UTC
    thanks man! i try the here document way myself too!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://292863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-12-08 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?