Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Perl On Win 98

by Anonymous Monk
on Jan 05, 2002 at 08:24 UTC ( [id://136474]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm trying to set up Perl on a Win 98 machine. Here is my script saved as both hello.pl and hello.plx
#!/usr/bin/perl -w print "hello world.\n";
If clicked on in explorer, they seems to work fine. However I get a Bad Command or File Name error if I type either name at the command line. My autoexec.bat has this line: SET PATH = C:\Perl\bin;%PATH%

Thanks, Paul

Edit Masem 2002-01-04 - Added code tags

Replies are listed 'Best First'.
Re: Perl On Win 98
by mkmcconn (Chaplain) on Jan 05, 2002 at 09:54 UTC

    pl2bat is a simple way to wrap your perl scripts in a batch file.

    c:\> pl2bat perlscript.pl
    produces a batch file that can be called as 'perlscript' from the command line. Comes as part of the ActiveState distribution. Read the pod for warnings, limitations and disadvantages as well as options available.
    mkmcconn
    added a helpful link.

Re: Perl On Win 98
by talexb (Chancellor) on Jan 05, 2002 at 09:28 UTC
    Hmm .. I'm currently on Win98 and have ActiveState installed and running fine. However, except for a few Rebuild This Web Site scripts, I run everything from the command line (actually, a 4DOS prompt, but a regular command line would work fine too).

    Open up a command line session and type path and see what you get. I get

    PATH=C:\PERL\BIN;C:\WINDOWS;C:\WINDOWS\COMMAND;C:\4DOS402;C:\PROGRAM F +ILES\MTS
    from my 4DOS session (and I get the same thing in my MD-DOS prompt -- I just checked). What do you get? (Hint: You should have C:\PERL\BIN somewhere in the path -- if not, that's the problem you should be solving.)

    With \PERL\BIN in your path you should be able to run your scripts from a command line. In fact, you should be able to run perl -v to find out your version level of Perl. (I get 5.6.0, build 616 from ActiveState, so I guess I'm up to date.)

    When I do run scripts from my desktop I enclose them in a BAT file that contains one line:

    c:\perl\bin\perl -w txtproc.pl
    I include the path so I don't have to worry about how the PATH is set. It's not the coolest solution -- running the Perl script would be cooler -- I probably ran into the same problem that you did and decided (after five minutes of fiddling) to work around it instead of solving the problem. TMTOWTDI.

    --t. alex

    "Excellent. Release the hounds." -- Monty Burns.

Re: Perl On Win 98
by mrbbking (Hermit) on Jan 05, 2002 at 08:28 UTC
    At the command prompt type this:
    perl hello.pl
    Your script is just a text file, it's not executable.
      Your script is just a text file, it's not executable.
      I'd have to disagree with that statement.
      Yes, it is a text file, but on most flavors of windows, the file association should be made when perl is installed(this is true with an ActiveState Installer). This file will not be opened by a text editor if clicked. It will be opened by "perl"(right clicking will present other options).
      Therefore on a command prompt:
      C:\>myscript.pl
      should work. It also means that double clicking on a file will open a command prompt and cause the program to be executed by the perl interpreter "perl.exe". if this is not the case you can set associations up in:
      My Computer->View->Options...->File Types
      of course perl myscript.pl is preferable becase it allows you to specify all the nifty command line options
        thunders - you're completely correct about how the ActiveState installer associates the 'pl' extension with perl.exe by default. But that's not the same thing as making files with a 'pl' extension truly executable.

        Notice that Paul says he tried typing the script name at the DOS prompt and got a "bad command or filename" in response.

        Double-clicking the file in Windows Explorer causes the filename to be sent to the perl.exe program, which then tries to parse and execute the code in the file. On my Windows machine, the command that Explorer issues when I double-click on a *.pl file is this:

        C:\Perl\bin\Perl.exe "%1" %*
        You mentioned the Windows 'File Types' dialog - while you're there, find 'Perl file', click 'Edit' - select the 'Action' called 'open' and click 'Edit'. Here's where you'll see that command line.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://136474]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-25 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found