Link to home
Start Free TrialLog in
Avatar of mwhitt
mwhitt

asked on

Testing Perl scripts locally

  ok, I got the interpreter, I got the HTML editor and I got the desire.

   What I don't have is the knowledge of how to invoke the scripts locally.

  The interpreter is in the f:/Perl/Perl directory, what I need is how to send the scripts to it.  
Avatar of ozo
ozo
Flag of United States of America image

From:
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ_1.html#1_7
1.14. When I double-click on the "perl.exe" icon in Explorer, I get an empty DOS
window with a blinking cursor. What gives?

Perl for Win32 is a Win32 command-line program. It expects to be run from the command line, not from
Explorer.

If you want to run a Perl script, write the script out using a text editor like Notepad. A good starter program
is:

    print "Hello, World!\n";


Save the program to a file on your hard disk (such as "C:\temp\hello.pl"). Now, start a command prompt
window (sometimes erroneously called a "DOS window"), and type the following line at the command
prompt:

    C:\> perl c:\temp\hello.pl


This should print out the words "Hello, World!" on the screen. You may have to do some fiddling with the
PATH environment variable, or specify the full path name to perl.exe, in order for this to work.

perl.exe has a lot of nifty command-line arguments that can make your work a lot easier. See the perlrun
documentation page for details.

To answer the original question about what's happening when you start perl from an Explorer window
rather than a command-line window: starting from Explorer is roughly the same as starting perl without any
command line arguments. When perl is started without a script file specified on the command line, it
expects to receive a Perl program as standard input, i.e., from the keyboard.

The blinking cursor means perl is waiting for your input. You can actually type in a Perl program from the
keyboard, and then let perl know to execute it by typing the Ctrl-Z key, which is the end-of-file marker on
Windows systems.

Avatar of mwhitt
mwhitt

ASKER

umm...possible cross question comment?

  ok, let me re-phrase.

  For example, let's say I write a guestbook script and create a form on a locally stored web page.

  What I need to know is how to test the said guestbook (I haven't actually written the script yet) without uploading it to the web server.

  I am not actually looking for the code for a guestbook, just a way to test Perl enhanced web pages locally (without uplosing them to my ISP provider).

  I hope this clears up the question.
 
You can run them like any other perl program, and see if the output
looks like the right html code.
If you used some of the nicer cgi modules to build it, you may be
able to pass query strings to it on the command line, or in stdin,
otherwise, you can set environment variables.
You can also run it through a local server on your own machine.
Avatar of mwhitt

ASKER

ozo,

  ok, a little Perl backround on me...there is none.

  I am just starting on Perl and need to find out, in layman's terms, how to test the scripts locally. I have web pages out tere and know quite a bit about HTML and such, but what I need is to test scripts locally because putting them on my ISP is a real hassle and I don't want to have to upload them more than once and have them work the first time I upload them.

  Also, I realize that I can run a server locally, however unless  one comes with Win 95 I don't have one.
Avatar of mwhitt

ASKER

btw, I tried your example from the first comment and I got something called a stub error (whatever that is).
So, the first step seems to be, how can you run _any_ perl program.
(Did any documentation come with it?  Perl normally comes with tons of
free documetation and FAQs.  I'm not sure about Win95 specific issues)
First of all, can you run the interpreter at all?
Can you type
perl
from the command line, and start typing perl code at it?
Avatar of mwhitt

ASKER

When I try to I get

Stub Error:
dos4gw
unknown directory

and no, I did not get any documentation...go figure.
The lack of documentation may prove to be a problem, as it sounds
as if your interpreter may not have been installed properly.
(like it's missing some library function in dos4gw, or it hasn't
been told where the directory is supposed to be)
I don't suppose
perl -v
or
perl -V
tell you anything?
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mwhitt

ASKER

ok, I finally figured it out.

 The interpreter I had was corrupted or something.  I go a new one and it works just fine.

thanks all

I am going ahead and giving ahoffmann the points for two reasons:

1. That was alot of typing.
2. The example probably works.