MelaOS has asked for the wisdom of the Perl Monks concerning the following question:

hi fellow monks~
i have come to seek thou's wisdom on some headache and insomnia inducing problems, i have...
i'm new to my company which uses a combination of perl, mysql,xslt,apache,javascript and axkit to develop web page. perl cgi is used for the interface, while xslt - style sheet, javascript - ajax, web validation.
so my problem is, where can i find more reference about how to properly learn all this? either books or websites?
there's a huge code base here but without any documents so i spend most of my time looking at a bunch of codes which i have no idea what they mean...another thing is that i've seen in all the pm scripts,(our perl are grouped into perl modules btw), is that this one lil line
1;
this after the basic use commands. i don't know what it does, but i was told that it could jam up the server if i don't include this line. any ideas what this does?
~thanks in advance

Replies are listed 'Best First'.
Re: what does 1; does?
by andreas1234567 (Vicar) on May 05, 2008 at 08:27 UTC
    perlfunc:
    The file must return true as the last statement to indicate successful execution of any initialization code, so it’s customary to end such a file with "1;" unless you’re sure it’ll return true otherwise. But it’s better just to put the "1;", in case you add more statements.
    See also this discussion (lists.netisland.net/archives).
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: what does 1; does?
by ikegami (Patriarch) on May 05, 2008 at 08:27 UTC

    require and therefore use execute the specified module just like a script. They expect the specified module to return a true value when executed. The return value of a module is the value returned by the last expression evaluated when the module is executed (just like for subs). 1 is a true value. You could change 1 to "A true value to satisfy require and/or use" (which is also a true value), and it would work just as well.

    This might be best explained by showing what happens when 1 is changed to 0:

    >type Module.pm package Module; # ... 0; >perl -e"use Module;" Module.pm did not return a true value at -e line 1. BEGIN failed--compilation aborted at -e line 1.
Re: what does 1; does?
by moritz (Cardinal) on May 05, 2008 at 08:40 UTC
    xslt - style sheet, javascript - ajax, web validation. so my problem is, where can i find more reference about how to properly learn all this?

    First you need to know HTML, if you don't know that already. There are many good books out there, but my HTML learning days are long gone. Same for Javascript and CSS. But searching for learn HTML or learn Javascript should turn up many good results.

    Ajax is just a javascript technique.

    If you want to learn perl, you can either read "Learning Perl" (if you have no programming experience) or "Programming Perl" (if you are already familiar with other programming languages.

Re: what does 1; does?
by stiller (Friar) on May 05, 2008 at 08:49 UTC
    It's not clear where you start out, but Learning Perl is a good book to start out with. It will help you up and go with useful basics. Thereafter you should probably get yourself a copy of Intermediate Perl, which explains modules and such. By the time you get through that you might have more spesific things you want to know, and "the Camel-book", Programming Perl, should end up on your desktop soon.

    Testing Perl and also Perl Best Practices are very good, and you might use them both to thumb through on the buss (or similar situations) to pick up new stuff and get inspiration.

    Related and very useful is also Mastering Regular Expressions.

    Take a look on the shelves of the people you work with, and ask them what they suggest you start with.

      hi fellow monks~
      thanks for the prompt reply, actually i've been using perl for over a year now mostly writing data extraction script from csv, excel and database. it's just that i haven't actually use perl cgi in combination with so many things at once. i was hoping that there is a name for such a thing, hehe, so i can easily find a good book which can cover all of these.
      thanks~
        Perl cgi really is a lot of things, or combinations. Finding one book that covers any combination closely is not likely. As you can see from some of the other responses, you will need to check out html and javascript if you're not familiar with them already. There is a very good html reference, "Dynamic HTML: The Definitive Reference", you'll find use for that one, but it's not an introduction.

        The hardest thing to figure out will probably be the indirection a webserver presents (here? there? serverside or clientside?) and on top of that the layers of a framework (how will the thread of execution flow through it all??) if you use that - understanding webserver and cgi will be a good start, but again, you need to check with your collegues what is used on your site, and if they have suggestions.

Re: what does 1; does?
by arc_of_descent (Hermit) on May 05, 2008 at 16:41 UTC
    perl cgi is used for the interface, while xslt - style sheet, javascript - ajax, web validation. so my problem is, where can i find more reference about how to properly learn all this? either books or websites?
    Since no one mentioned it, I'd like to point out the excellent Tutorials section here in case you missed it.

Re: what does 1; does?
by Anonymous Monk on May 05, 2008 at 11:30 UTC

    Practice grammar and spelling English. Programming work requires precision and an eye for detail, which you evidently lack. If you really want to affect a capital-less style, then you'd better be dead perfect on everything else.

    "Thou" is essentially archaic, but you've managed to violate three rules at once with it. First, it is singular only, never used to address more than one person; second, it is the familiar form, used for intimates, pets, and children. It is insulting to use it here when asking for advice. Third, "thy" is the word form you were reaching for, although "y'all's" is of course, the correct term.

      although "y'all's" is of course, the correct term.

      Please, please. In my neck of the woods the proper term is "youse" as in "What's the matter with youse guys"...

        Not!
        "What's the matter with youse guys"...

        should be

        "Whassa mattah wid youse guys?"

        Anybody'd tink you donne spik no Brooklyn Inglish.

      It is really amazing how many people seem to think communication does not have much of a roll in programming and software development. On the contrary: it is key! After all, the programmer is communicating with at least two entities, namely the computer itself, and the end user. Having a sound grasp of the English language (or whatever natural language the program is to be used in) is very important. I have seen a great many programs with spelling and grammatical errors, but also containing nonsense in messages (not computer speak, but English words strung together that actually made no sense in any conceivable context).
        Can't resist pointing out

        roll -> role

        ;-)

        Oh, the irony

        Chris

Re: what does 1; does?
by educated_foo (Vicar) on May 05, 2008 at 14:35 UTC
    Books about Perl (and most other "technologies") are mostly a waste of money. Perl itself comes with excellent documentation and many examples, as do most widely-used modules. People on Perlmonks are usually quick to answer questions not found in these docs.

      Oh, I can think of several books which cover things most definitely not found in the documentation....

        True. For example, the Ruby/Rails guys figured this out and wrote a language and framework with completely shoddy documentation, thus creating a wonderful book market. Luckily, Perl hasn't followed this path.
      All too true!

      But nothing beats having the Camel book on your desk, if nothing else it identifies you as an "old hand" in programming (so does having the COBOL and FORTRAN programming manuals lying around, although you have to lock these up in safe storage when you are away as they have antiquarian value now).

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James