Solved

Testing Perl scripts locally

Posted on 1997-10-02
10
255 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating the data using Oracle DBD module. 5 65
delete query using perl dbi 3 96
transpose into pipe delemited 8 67
Move Function in Perl Script 2 65
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…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

864 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

22 Experts available now in Live!

Get 1:1 Help Now