Solved

Testing Perl scripts locally

Posted on 1997-10-02
10
270 Views
Last Modified: 2012-08-13
  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.  
0
Comment
Question by:mwhitt
  • 5
  • 4
10 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1207603
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.

0
 

Author Comment

by:mwhitt
ID: 1207604
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.
 
0
 
LVL 84

Expert Comment

by:ozo
ID: 1207605
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.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:mwhitt
ID: 1207606
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.
0
 

Author Comment

by:mwhitt
ID: 1207607
btw, I tried your example from the first comment and I got something called a stub error (whatever that is).
0
 
LVL 84

Expert Comment

by:ozo
ID: 1207608
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?
0
 

Author Comment

by:mwhitt
ID: 1207609
When I try to I get

Stub Error:
dos4gw
unknown directory

and no, I did not get any documentation...go figure.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1207610
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?
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 50 total points
ID: 1207611
try following batch script, it must be called with the extension (.bat) otherwise there must be a more tricky solution at the  perl.exe  call (see %me% variable).

[------------------- snip here --------------------]
@REM = '
@ECHO OFF
SET me=%0
SET args=
:_args
IF "%1"=="" GOTO _endargs
SET args=%args% %1
SHIFT
GOTO _args
:_endargs
F:\perl\perl\perl.exe -S %me% %args%
GOTO _exit
@REM ';

print "write your perl script here, down to the __END__ directive.\n";
exit(0);

__END__

:_exit
SET me=
SET args=

0
 

Author Comment

by:mwhitt
ID: 1207612
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.


0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question