Can we run a Perl script in a browser without web server? - perl

Is it possible to run a perl script in Activeperl without web server in windows 7.If possible what are the steps to follow?
I have simple registration form using Post method in HTML file.I'm using this HTML file in my .pl file.I'm using CGI module. While running the .pl file from the command promt the HTML file is running browser, after clicking submit button the perl script is displaying.

When you install ActivePerl, it creates a file association for .pl files, so simply double-clicking a .pl file in Explorer ("My Computer", "File Explorer", etc) will run it. This also makes it so you can run script.pl from the Windows Command Prompt.
When you install ActivePerl, it modifies your PATH to include the directory that contains perl.exe, making it so you can run perl script.pl from the Windows Command Prompt.
Finally, you can always run c:\...\bin\perl script.pl from the Windows Command Prompt.

Can you explain a bit more the exact use-case?
I think the first user in the comments gave you the best answer.
If Perl is not in your PATH environment you need to associate .pl extensions with Perl or run it via command-line ( if I remember correctly Active-Perl comes with a Perl command line tool )

Related

How to silent install an exe file using perl script

I want to silent install a software executable file using Perl coding.
I check to have a installer module to run executable file but no luck.
Kindly respond with some idea to initiate .
Would it not make sense to do something like that in a .bat or .ps1 file, using the command:
vlc-2.0.1-win32.exe /L=1033 /S
(just put the full filepath and executable file in there)?
That should result in a silent install, and looks easier for Windows than trying to use Perl? Or does it have to be Perl for whatever reason?

Adding perl script to module distribution and making it accessible globally

I'm wondering if there is a tutorial or simple way to add perl scripts which I've written to be accessible to the user globally.
for eg. you apps like Carton, Cpanm, much like how npm has an npm install -g option.
I tried placing my scripts in the bin directory of my perl package but its not working.
The App::* area of cpan contains installable tools and utilities. Looking at a small one, like App::p I saw that its structure looked like it contained a Makefile.PL that used ExtUtils::MakeMaker to define how to build test and install the relatively small perl script.
However, if you're talking about just taking a script you wrote and making it something executable by you, the user, then it's basically the same way all scripting works (apologies if you weren't asking this):
One Unix, Linux and Mac OS X when using a shell like bash:
Any file can be made executable to the user by running chmod u+x filename
An executable file should start with a magic number, for plain text files containing scripts, the shebang is that number. So start your files with (as covered in man perlintro):
#!/usr/bin/perl
use strict;
use warnings;
When specifying an executable file from the command line you can type in the full path, possibly with conveniences from your shell. EG the file is at $HOME/myscripts/runme.pl you can type that at the prompt, the expanded /home/username/myscripts/runme.pl (/Users/username/myscripts/runme.pl on Mac OS X) or ~/myscripts/runme.pl at a bash prompt. Or if runme.pl is in your current working directory: ./runme.pl
If you just type runme.pl sh and bash and many shells will search your PATH variable in order and run the first runme.pl in any of the specified paths.
So if echo $PATH gives you something like: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin and you want the example in point 3 to work with just runme.pl you should
Either move the file into one of those directories (not recommended).
Or add export PATH=$PATH:$HOME/myscripts to the bottom of your ~/.bashrc or ~/.profile file or likewise for your preferred shell. Be sure to open a new login shell session, EG close that terminal window and open a new one.
On Windows, this is an exercise left to the reader. ☺

Cannot run any Perl scripts on Windows 8.1

I installed Active Perl 5.20
and also Strawberry Perl 5.20 after uninstalling Active Perl.
In both cases, when I open cmd and type 'perl' I get:
Unknown Unicode option letter ':'.
This error also prevents all scripts from running on my Windows 8.1 installation.
I uninstalled Perl and did a fresh install and it still doesn't work.
Are there dependencies that I need to install?
I googled the error but the results pertain to Linux installations where the script specified something wrong. But I get this error when I even try to use any perl command line or script. So my problem is not a faulty script.
That is the error message you get from using an invalid value for the -C command-line option. At a guess I'd say you have the PERL_UNICODE environment variable set to a string that contains a colon :.
Take a look at Command Switches in perldoc perlrun for more detail on this.
I too had this problem on windows 8.1 . The problem is that, once on installation, .pl files are not automatically recognized by Perl engine. So please select a .pl file and right click and say open with and set the default program to C\perl\bin\ inside it click perl.exe and recognize it. Once this is done your perl works flawlessly.

How can I run a Perl script with ActivePerl?

I just recently installed ActivePerl 5.12.2.1202 on my Windows XP in C:/Perl. I am new to Perl scripting.
I just want to run a Perl program which contains one print statement, which I saved in Notepad with the name ex.pl.
How can I run this Perl program?
Can I use an editor for typing a Perl script other than Notepad?
How do I use ActivePerl?
Run Perl program from command prompt
start->run>cmd (command prompt will appear), write perl full_path_of_your_script,
like
C:\> perl hello.pl #This assumes that perl is in your PATH environment variable.
There are many Perl Editors, you can
used for Perl scripts like DzSoft,
Perl Expess, Komodo Edit etc and also see http://www.perlmonks.org/?node_id=169668 and Perlfaq3- Windows Perl Editors for more detail.
Have a look at http://docs.activestate.com/activeperl/5.12/, for ActivePerl 5.12 documentation.
Perl programs (or any other program run by an interpreter) is run by passing the script as a command-line argument to the interpreter. For example, in this case:
perl.exe ex.pl
Padre the Perl IDE and Kephra are good editors for Perl.
As an alternative to ActivePerl, there is Strawberry Perl.
Perl programs are run using the Perl interpreter, perl.exe.
This is normally done from the command line:
C:\>C:\Perl\bin\perl ex.pl
If perl.exe is in your PATH environment variable that can be shortened to:
C:\>perl ex.pl
If you opted to have *.pl files associated with Perl during installation, you can also double-click on them from Windows Explorer.
If you have *.pl files associated with Perl and add .PL to your PATHEXT environment variable you can run them like any other executable:
C:\>ex
Perl programs are just text files. They can be edited with any text editor (Padre, Kokomo, vim, emacs, Notepad++, etc.). Use whichever one you like best.
ActivePerl is just a distribution of Perl. "Using" it usually means running perl.exe to execute your program. ActivePerl also includes the PPM (Perl Package Manager) utility to make it easier to install modules from CPAN, particularly if you don't have a C compiler available. Most experienced Perl developers prefer to use the cpan shell.
Just to add to the other answers, I use EPIC, the Perl eclipse plugin. I'm using Perl on a Windows 7 64 bit machine.
I still run scripts off the command line in windows using ActivePerl, but for development I like being able to dynamically step through the script line by line.
just to not paraphrase other answers and to be more helpful (even if the post is somehow old ) i recommend using the switch "-e" to run Perl scripts if they are composed of few statements e.g
Perl -e "print('hello')"
and of course this requires that the Perl executable is in the Path variable,if not and assuming Perl is under the folder c:\Perl , you can add it by taping :
set %PATH%=%PATH%;c:\Perl\bin
when it comes to the choice of text editor ,I'm still using Notepad++ for almost everything ,it come with some useful features like keywords highlighting and some auto-completion capabilities.

Perl execution from command line question

I replaced ActivePerl with Strawberry Perl on my WinXP last week.
I found I must run my Perl script with the command of perl myperl.pl; otherwise I only need run myperl.pl before install Strawberry. How can I only run myperl.pl as before?
I checked my environment configuration as below.
C:\> Path
C:\Program Files\ActiveState Komodo Edit
5\;C:\Perl\site\bin;C:\Perl\bin;C:\Perl\bin\;C:\Program Files\CodeSynthesis
XSD 3.2\bin\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;
C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Microsoft
SQL Server\90\Tools\binn\;C:\Program Files\Common Files\Thunder Network\KanKan
\Codecs;C:\strawberry\c\bin;C:\strawberry\perl\bin`
Strawberry Perl path already listed in the Path value after install successfully.
Anything I missed? Thank you for your suggestion.
Try from command prompt:
assoc .pl=PerlScript
ftype PerlScript=c:\strawberry\bin\perl.exe %1 %*
--
kmx
You need to associate .pl file extension with Strawberry Perl's executable (it's a Windows thing, not a Perl thing).
To do so, there are a couple of ways (you can google or ask on ServerFault for the best one or full list), but the one I usually use on XP is:
Open any folder Windows Explorer
Go into "Tools" menu, and click on "File Types" tab in the resulting dialog
Find "PL" extension in the list
If it's there, correct the associated executable to be Strawberry Perl's .exe by clicking on "PL" line and clicking "Change" button
If it's not in the list, click "New" button, type in PL extension in the form and click "OK". Then close the whole dialog, and re-open it again. The "PL" extension will now be in the list, so click on it and click "Change" button
In case I messed up, here's the official instructions from Microsoft:
http://support.microsoft.com/kb/307859
UPDATE
Please see kmx's answer - his method is all-command-line and as such seems much more preferable to me that GUI blundering... I confirmed that it works too (without parameters, at least)
You might need to put the .PL extension into the PATHEXT environment variable. This will make .pl files work with the PATH variable.
Type
set PATHEXT
to see if you're set up. If you're not, then go to My Computer->properties->Advanced and press the "Environment Variables" button on the bottom of the tab. There you can add .PL to the PATHEXT variable.
OR you could just set it in some batch file that you run to initiate cmd:
set PATHEXT=%PATHEXT%;.PL
For completeness here's 2 other methods that don't make a .pl script executable, but you could use them to make your perl script into an executable.
pl2bat which is suppose to create a wrapped version of your .pl into a .bat file which would be executable on a windows system. I haven't tried this so YMMV.
pp, part of the PAR::Packer module which I have used before works pretty well at rolling your perl scripts into executables.