Hello all, Greetings!

Question: How does one run a perl program without it being a cgi program? Can I write a script in perl as a stand alone program and run it without uploading to the http server? if so How?
I have saved my files with a .pl file extension. When ever I double click to run a black box momentarily appears, one looking like the command prompt. But it goes as soon as it arrives. thanks in advance for the solution to my question

Windows?

Open a DOS window, and type:

perl name.pl

if perl is not in the command path:

c:\perl\bin\perl.exe name.pl

if the program is not in the same directory:

perl c:\path\to\name.pl

Thats the way I do it anyway.

A better alternative is to use an IDE. Perl Express is a free one for Windows. www.perl-express.com

Then you can write/edit/run programs in the IDE. Makes it easy to write programs and test them. I believe perl-express also has CGI and interactive I/O input options so you can feed data to the script like you would with a CGI script or command line program.

You must still have perl installed to use the IDE.

Hi KevinADC,

Thanks for your effort and reply. I did try your second suggestion by typing it in the run command in the start menu (am using windows XP, Home edition). It may have worked except that the resulting window flashes across the computer screen, rather than remaining on the screen. So I dont know for sure what is happening. Am just beginning to learn perl and not quite au fait with things yet. Below is the short code I've written and attempting to run:

#!/perl/bin/perl
print "content-type: text/plain\n\n";
$exRate=1.35;
$USTotal=50.00;
$CDNTotal=$USTotal*$exRate;
print "$USTotal American dollars is equivalent ". 
"to $CDNTotal Canadian dollars.\n";

Any further assistance will be greatly appreciated.

jimwall80

Open a DOS window (MS DOS Prompt)..... then try my suggestions.

You need to download and install the perl interpreter. From the looks of things, you don't have it... http://www.perl.com/download.csp
To check if you do, just type "perl" into command prompt, and it will reply with a version number and some information. Anyway, to use the perl interpreter, put the script into a plain text file and save it wherever you want. In command prompt, change directory to that folder, and then type "perl file_name.pl"
it should run

an MS-DOS window is different than running it from the run command... if you just run it from the run dialog it will open the window, run the program, and then close when it is finished. From an MS-DOS prompt it does the same thing, just if it is run in the DOS window, then when the program exits, the DOS program remains so the window remains open... the command prompt window is more or less just a program that runs other programs, it's like if the run dialog showed the output of the programs you ran from it.

From an MS-DOS prompt it does the same thing, just if it is run in the DOS window, then when the program exits, the DOS program remains so the window remains open

Exactly, which is why I recommend running perl programs in a DOS window.

Just go to the command line and run the program. Open a cmd or shell and type "program.pl" and it should run. If it doesn't try "perl program.pl"

Sorry, if need to install the perl interpreter. I use Active State perl on Windows. http://www.activestate.com/ Just dowload the free distribution and by pass the sign up.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.