http://qs321.pair.com?node_id=922653

perl.j has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,

I would like to start basic web programming with Perl. But I'm afraid I have no prior knowledge of anything to do with web servers, or anything else that I would need to know before hand. Do I have to know about the basics of web programming before starting to program?

Also, what would I use to web program in Perl? Is it built-in to Perl? Or do I need to use a module? Do I have to have a web server (excuse my knowledge, but I'm afraid I don't even know what a web server is)?

Thanks in advance for the generous help. You guys (and girls) are awesome.

--perl.j

Replies are listed 'Best First'.
Re: Web Programming: For Beginners
by blue_cowdawg (Monsignor) on Aug 26, 2011 at 14:57 UTC

    First off:

        Do I have to have a web server (excuse my knowledge, but I'm afraid I don't even know what a web server is)?

    There's something in terms of "the basics®" you need to learn. By definition you need access to a web server to serve your pages from. Secondly,

        Also, what would I use to web program in Perl?
    You are probably getting way ahead of yourself. Try renting shared space on a web server somewhere. Hosting plans are as little as US$1 a month these days. Start off by learning HTML and serving up static pages. If you try to learn Perl web programming and just the task of creating HTML pages you are going to get lost.

    Having said all that and once you are comfortable with concepts of HTML start checking out the Tutorials here at the Monastery. There is a whole section on web programming that if you try to learn it all at once your head will a'splode.

    My advise to you is to start off very simple, follow some of the examples in the CGI man pages and don't move on until you understand them thoroughly.

    Make sure that whatever hosting plan you get yourself into, or whatever server you end up posting your work to is configured to allow CGI programs to run on them. Some don't for security reasons. Some don't at the "economical" hosting plan levels because they want to charge you more for the privilege. So choose wisely.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
      While understanding the basics like what a web server is is important to web programming, one doesn't need to rent hosting on a web server to dip their toes into it. You can run a web server on your local system, and test apps from it. A framework like Dancer makes this easy (or Ruby/Rails or Catalyst or ... for that matter), you can launch any app you develop on the "built in" server, and when you decide you want to deploy your app to the world, then you can rent hosting and run your app on a more capable server.
            one doesn't need to rent hosting on a web server to dip their toes into it. You can run a web server on your local system, and test apps from it

        In principle I agree with what you said. In point of fact when I do web programming I do all my testing on a localized web server until I'm sure the code is ready for Prime Time®.

        I confess to being leery of telling a beginner to set up a local web server. Using a web server and setting one up are two different things. Having seen a lot of questions on the Monastery surrounding web server configuration I think learning to use a web server and learning to set up of your own should be kept as two separate learning paths.

        Indeed I have worked with a great number of application folks who write wonderful web applications but don't know spit about setting up or maintaining the web servers they target their code to.


        Peter L. Berghold -- Unix Professional
        Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
      There's something in terms of "the basics®" you need to learn.

      What do you mean?

      --perl.j
            What do you mean?

        By basics you need to learn what the moving parts of web "programming" is all about. Understand the relationship between your application (or static pages) and the server they are being hosted on and what is involved in the user experience of accessing those.

        The fact that you stated you don't even know what a web server is tells me you are at the parking garage level of understanding and you want to get to the penthouse.

        Just like learning how to play a game you need to understand the rules and in the case of a sport such as football or soccer you sometimes even need to understand the rationale behind the rules.

        Knowing what a web server is and what it does for you and how it does it is a good place to start on your journey towards learning how to do web programming. There is pain in the learning (pain is weakness leaving your mind) but the rewards for going through that pain are paid off when you get to the point you are doing actual programming and understand what is happening to your code in that environment.

        Steps:

        1. gain an understanding of the web programming environment. Such as what web servers are out there, what they do and how they do it. How does DNS affect your web programming environment? What is browser independent coding all about?
        2. gain an understanding of basic HTML. What are the rules of good markup?
        3. (optional) learn some javascript. This will come in handy later on.
        4. Read the Tutorials on web programming here at the Monastery
        5. Look at the documentation for CGI and understand the examples. Thoroughly.
        6. Come up with a simple (and I stress, simple) web application and avoid the temptation to jump right in and try to write that "killer app" for all your friends to ooh and ahh at. You're not ready at this point and you are setting yourself up for Epic Fail®.

        That will keep you busy for a while, keep you off the streets but hopefully not interfere with your studies. :-)


        Peter L. Berghold -- Unix Professional
        Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Web Programming: For Beginners
by chrestomanci (Priest) on Aug 26, 2011 at 15:21 UTC

    That is a big vague question. The kind I would ignore if it came from a newbie, but seeing as you are known around here, I will bite.

    Firstly, unless you want to do everything the hard way, you need to use some modules from CPAN, so make sure it is warmed up and ready to go. :-)

    What are you trying to achieve? Do you just want to learn, or do you have something specific in mind? I find that when learning it is always best to have a project in mind.

    For example, for a simple project you could just wrapper the output of a system command on your computer and serve it up through the web server. For a simple project like this the CGI module will work well.

    For example if you have a linux computer, you could wrapper a command like free or uptime and return it nicely formatted.

    If CGI feels to primitive, or you want to work with templates or databases, then you need a web framework such as Catalyst or Dancer. (There are probably others). Personally I have used Catalyst quite a bit, and like it, and I have no experience with Dancer. Others here will be able to offer their opinions on which is better.

    To suit one of those powerful frameworks, you need a more advanced project, and I suggest you look at one that makes use of a database back end. For example you might build a database of your MP3 collection. Music::Tag::MP3 Will read ID3 tags from your music files and DBIx::Class::Manual::Example has detailed examples of how to construct a database schema of a record collection. Once you have done the exercises in Catalyst::Manual::Tutorial you should be able to create a Catalyst application that will let you search your music collection, by title, artist, album etc.

      Sounds simple enough. Just one thing. How would I "serve it up through the web server"? What is a web server?
      --perl.j
            What is a web server?

        Offsite link: full definition of a web server

        Google is your friend.....


        Peter L. Berghold -- Unix Professional
        Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
        A web server is the system that listens for web requests and serves up the responses. Your browser is making requests almost every time you click on something, and then the browser displays the response.

        In this context a web server is a computer program that listens for requests coming from the internet, and responds to them.

        To use CGI you need to install one on your computer. I recommend Apache. If you are running linux then it should be easy to install. If you are not running linux, (or Mac OS X) then everything will be much harder.

        If you chose to use a framework like Catalyst, then they usually come with a built in web server that is suitable for debugging and very light traffic.

Re: Web Programming: For Beginners
by luis.roca (Deacon) on Aug 26, 2011 at 16:02 UTC

    Hey perl.j

    It seems like you asked this question already:
    Creating a Website in Perl

    You were given some pretty good answers there along with enough direction that, with a little investigation, you should not have felt the need to ask the question all over again. If you weren't clear on the answers you got - respond and say so in that thread or follow up in the CB. It honestly ends up being a little disrespectful and somewhat of a waste of time to everyone who took time out of their work or away from families to help you.

    That said, if you want to learn how to build websites, prerequisites etc check out http://developer.mozilla.org and maybe also the Stackoverflow site for web development. Anyways, good luck and have fun learning :)

    "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." — Don Quixote
      I know luis.roca and I'm sorry. But I also a feel this is a somewhat different question.
      --perl.j
         

        "...But I also a feel this is a somewhat different question."

        But it isn't. The questions are pretty similar: "How do I build a website?" You just asked them slightly differently but it's the same question. Which means you still weren't clear from the first time you asked it. That's completely fine and normal for beginners to need more explanation. As I said in my first reply, if you are still unclear follow up on replies in that thread or the CB asking for further explanation.

        My broader point is that it seems to me you are NOT following through on the information people are spending their time providing in replies to your questions. In other words it's clear:
        You're not doing your homework.

        I'm not trying to be harsh just very clear because you are not going to benefit all that much the way you're currently approaching learning here (or anywhere). Learning is hard. Learning to learn can be even harder. Otherwise there would be no PerlMonks, schools etc. So people here will cut you some slack — up to a certain point. :-)

        I think I've said something like this before but I'll repeat it one more time:

        • Slow down.
        • Focus. Learn one thing at a time.
        • When you get stuck, struggle with it for a while and try to find answers on your own.
        • When you've made a bunch of attempts to find answers with no luck then spend time writing a well thought out (specific) question.

        I understand the feeling that you have to learn a bunch of different things all at once. It's overwhelming. HTML, CSS, Perl, SQL etc. — It IS a lot but you're in high school so benefit from something I and others don't have as much of — TIME :-))

        Please read through:

        "...the adversities born of well-placed thoughts should be considered mercies rather than misfortunes." — Don Quixote
Re: Web Programming: For Beginners
by zentara (Archbishop) on Aug 26, 2011 at 16:18 UTC
    Look at XAMPP It is a single download that will get you setup with most of the things you need. You don't say what platform you are on, but if you are on linux, you can easily install all the XAMPP components yourself, but XAMPP makes it very easy to get started, no matter what your platform.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      I am using a Windows 7 computer, 64-bit computer.
      --perl.j
Re: Web Programming: For Beginners
by trwww (Priest) on Aug 26, 2011 at 18:41 UTC

    Oreilly has a cool program called Open Books that lets you read some out of print books online.

    See the book CGI Programming on the World Wide Web. Yes, this book is 15 years old. But it explains the basic tenets of the WWW in a simple manner.

    You don't want to write production software based on the code in this book. After finishing it you'll want to start looking at libraries like CGI::Appication. But if you read this book first and understand it, you'll be able to quickly pick up what it is that tools like CGI::Application or Catalyst... or even apps like ASP.NET or Java Spring do, and be able to quickly realize the feasibility and/or limitations of different approaches to solve tasks.

Re: Web Programming: For Beginners
by metaperl (Curate) on Aug 26, 2011 at 19:39 UTC
Re: Web Programming: For Beginners
by sundialsvc4 (Abbot) on Aug 29, 2011 at 00:10 UTC

    Start with ... web research.   Given that you know, both that you are venturing down a well-known path, and that you nevertheless do not yet know where the rocks are ... make it your first business to look before you leap.   Do your homework.   Avail yourself meticulously of everything that the web has to offer, then, by all means, come back here.

    Also:   gather information before you attempt to react to any of it.   Recognize that you are getting into the swimming pool for the very first time.   There is no shame in this, because of course every one of us started out in the selfsame way.   But there is in this the stern admonition that you have much to learn, and that you very much need to hold your enthusiasm in check.   Gather information for ... say ... at least two consecutive weeks of working-time ... before you attempt to respond to any of what you have gathered.

    You are in a pool for the first time, but you are hardly the first one to take a swim.   There is deep water here, and there are shallows.   Lifeguards are on duty at some (clearly posted) times but not others.   A stack of life-vests is stacked neatly nearby, along with water-wings and other goodies.   A poster on the wall by the restroom describes swimming-lessons that are offered twice a week.   You are going swimming for the first time, but you are clearly also surrounded by resources, information, and experience.   Plan Accordingly.   Success favors the well-prepared.   (The others drown very narrowly escape.   I hate sad endings.)   No one can learn to swim just by reading a book about it but ... hey, this is a pool at a resort! ... you can read that book at your leisure, sitting by the pool and sipping a nice foo-foo drink with an umbrella in it.   (It’s your fantasy, so why not?)

    During the next calendar week, make it your business to have read at least five hundred postings on this site, and at least five hundred on other sites, before you attempt in any way to “do” ... absolutely anything.   Even if you feel beyond a shadow of a doubt that you understand what to do ... perfectly.   Assume, please, that you (don’t yet know that you...) don’t.   Please.   Do not ask me why, do not question.   Just listen.   Just.   Please.   (You will thank me.)   (I think.)   (Having done this crazy thing for thirty-plus years now, I’m probably right.)   (I think.)