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

Hello. Please forgive me. I'm a Perl newbie. I went out and bought the Llama book tonight, downloaded ActiveState ActivePerl 5.6 on my Windows 2000 system... and I can't get even the simplest "Hello World" program to work. To tell you the truth, i don't know where to even begin to get it to work. When I double click the Perl 5.6.1 exe file, I get a command screen. But no matter what I type, I get nothing... I can't get perldoc... or anything... This is frustrating, and I don't want to give up just yet. Can somebody point me out to a step by step, very basic, spell it out exactly what I need type of resource? How do I get past the first chapter in this book (completing all exercizes in a workable environment). Please help!

Replies are listed 'Best First'.
Re: Perl Dumbass needs a hand-holding
by grep (Monsignor) on Jan 03, 2002 at 13:44 UTC
    The easiest way to get started is to open a DOS window. Change to the directory of your perl script and type 'perl scriptname.pl'. I like this because I can rapidly test by hitting F3 (in win9X) or up arrow (in 2000).
    You can also check the activestate docs on how to setup your extensions (sorry don't remember off the top of my head)

    PS don't think of your self as a dumba** we've all been there, picking up the Llama book is best step forward you can make.

    grep
    grep> cd pub grep> more beer
Re: Perl Dumbass needs a hand-holding
by seattlejohn (Deacon) on Jan 03, 2002 at 14:13 UTC
    Prior posters have explained the basic idea, which is that you want to run the Perl interpreter from a command-line prompt, with a specific Perl program for it to run, rather than double-clicking within the Windows GUI.

    Since you're running on Win2K, one additional trick that you can use is to set the PATHEXT environment variable so that Windows knows programs ending in .PL are executable (by calling the Perl interpreter). Try this at your DOS prompt:
    SET PATHEXT=%PATHEXT%;.PL
    Then you can just type:
    myscript
    at the command line, and in addition to the usual myscript.exe, myscript.com, and so forth, Windows will look for myscript.pl. And since it knows .pl is associated with the Perl interpreter (thanks to the ActiveState setup), everything should run. If you want to make it permanent, you can go into Control Panel | System | Advaned | Environment Variables and make the change there. (Caveats: To the best of my knowledge this will work on any NT-derived system including XP, but not Windows9x/ME. Also, it does have some limitations if you want to use your programs to do piping/filtering, but that probably won't be a concern for you in the near term.)

    Running the perl interpreter without any filename can be vaguely useful under certain circumstances. Specifically, you can type in a quick-and-dirty program and have it interpreted on the spot -- the trick is that you need to press Control-Z to send an end-of-file marker so that Perl knows you're done sending it input. I don't often find this useful in practice -- I like to save code I've written! -- but if you want to make "Hello, world" work in a totally non-reusable way, you could do this:

    perl[Enter] print "Hello world!";[Enter] [Control-Z][Enter]

    Anyway, good luck... stick with Perl through some of the initial frustration and you will eventually wonder how you ever lived without it!!

(cLive ;-) - newbie, setting up file associations
by cLive ;-) (Prior) on Jan 03, 2002 at 14:15 UTC
    ActiveState install sets up file associations for you, but when you (double) click a script to run it, generally a DOS window opens, it runs, then the DOS window closes before you get a chance to see the output (well, that's how my Win 98 machine seems to behave).

    Stick to a shell. Hint - set up doskey to run when you open it, it makes things a little easier (but nowhere near bash though ;-) - create a shortcut to a 'DOS window'. Right click, choose 'Properties', enter 'DOSKEY' in the batch file line. Shazam, your up arrow then goes through the history of what you've typed.

    cLive ;-)

      I agree with "stick to a shell" but PLEASE don't promote any DOS shell for the original poster who is on Win2K.

      <rant>

      The CMD.EXE shell in NT4 and Win2k is much more powerful and useful than the (backwards compatable use only) command.exe (aka the DOS prompt)

      With cmd.exe you don't need the DOSKEY command...cmd is a real shell, command is a afterthought put into Win9X and then into the NT code base. It is bad bad bad and should be avoided at all costs.

      </rant>

      "Nothing is sure but death and taxes" I say combine the two and its death to all taxes!
        Sorry,

        Never use it myself since I'm generally on Linux, and since they seem to be a newbie, I didn't want to suggest something too useful (with a steeper learning curve like Cygwin :-)

        cLive ;-)

Re: Perl Dumbass needs a hand-holding
by claree0 (Hermit) on Jan 03, 2002 at 13:47 UTC
    The easy way to do this is to create the perl script using Notepad. Save it into a directory on your PC (e.g. c:\tryout\hello.pl). Bring up a command prompt (start-run-cmd on NT or 2000, start-run-command on 95/98), and cd to that directory (cd \tryout), and then perl hello.pl
      I totally agree, except I'd like to enter a slightly OT pl{ea||ug} for EditPad (with which site, I hasten to add, I have no connection except as a satisfied user). The "Classic" version is freeware, and replacing Notepad with this excellent bit of kit improved my productivity and sanity appreciably.

      § George Sherston
        Imagine how happy I was when I found VIM for windows. Take that notepad.

        Thanks,
        Dru
        Another satisfied monk.
        Likewise, SynEdit is an excellent free editor - and when I program under Windows I will invariably use it - it has profiles for various languages.

        I have no connection to this product, except as an equally satisfied user!

Re: Perl Dumbass needs a hand-holding
by archen (Pilgrim) on Jan 03, 2002 at 20:07 UTC
    Something else that might help you down the road: If you need to hold a command prompt window open (since they typically close when a program/script is finished), you can put
    <STDIN>;
    On a line by itself, and the program will wait for you to press return.
A reply falls below the community's threshold of quality. You may see it by logging in.