Solved

Testing Perl scripts locally

Posted on 1997-10-02
10
249 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:mwhitt
Comment Utility
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
Comment Utility
btw, I tried your example from the first comment and I got something called a stub error (whatever that is).
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 84

Expert Comment

by:ozo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now