[Newbie] Running a Perl script on Windows

J

Juergen Fenn

Hello,

I am new to Perl so would you please apologise if this is an FAQ I
didn't read about earlier. I have the Lama Book here and I have had a
look into the ActivePerl FAQs, but I can't find anything about it. I
probably don't know the correct term to search for.

This is my question:

I have tried to use html2latex with ActivePerl 5.8.0 on my Windows 98
system recently. It works well when I put the script in the same
directory as the HTML file to be processed by the script. I call the
script using "perl html2latex myfile.html" from that same directory.

Now I put it in a directory that is in my PATH for further usage. It
doesn't work.
Perl does not find the script.
However, _I_ can find the script when I enter "which html2latex".

But where exactly does Perl look for scripts?

I tried to put the file in one of the directories other than "." that
are in @INC, but this didn't work either...

Do I have to write a DOS batch file for running Perl scripts that are
in my PATH?

Thanks in advance!
Juergen.
 
J

Juergen Fenn

Purl Gurl said:
Expanding on this, if your to use your latex program
frequently, you can modify your Win98 autoexec.bat
to automatically include a path which can be used in
any directory, you only need to issue,

html2latex

for any given directory when a parent path is set in
your environment variables through an autoexec.bat file.

Thanks for answering. Now, this is exactly what I tried before. I
saved html2latex in a directory that is in the PATH set in my
autoexec.bat. This works with exe and bat files, as you wrote, but it
does not work with a Perl script here:

D:\Dateien\temp>perl html2latex.pl myfile.htm
Can't open perl script "html2latex.pl": No such file or directory

Renaming the script to exe/ bat, as you suggested, does not work
either.

Only using full paths both to html2latex as well as to the HTML file
to convert has solved the problem. Thanks for your advice! :cool:

However, the question remains why does Perl on Windows not find the
script in my PATH?

html2latex contains a readme file for use on MS Windows suggesting
this should be the case:

You can put html2latex anywhere you want. Putting in your path makes
command-line usage very easy, however.

Thanks!
Juergen.
 
M

Matt Garrish

Purl Gurl said:
(snipped)


perl c:/your/path/to/html2latex myfile.html

A presumption is made "html2latex" has an executable
extension such as ".exe" or ".bat" so DOS can run it.

Why would you call the perl interpreter on a file that is actually an
executable or batch file? Did you get confused between typing your command
and writing the explanation?

Matt
 
M

Matt Garrish

Juergen Fenn said:
Thanks for answering. Now, this is exactly what I tried before. I
saved html2latex in a directory that is in the PATH set in my
autoexec.bat. This works with exe and bat files, as you wrote, but it
does not work with a Perl script here:

D:\Dateien\temp>perl html2latex.pl myfile.htm
Can't open perl script "html2latex.pl": No such file or directory

Renaming the script to exe/ bat, as you suggested, does not work
either.

Her advice is usually wrong. Your problem is that you're invoking the
interpreter to call the script, and the interpreter does not care what
system paths you have specified. You must call your script with an absolute
or relative path if it is not in the same directory where you're trying to
invoke it. Otherwise, perl will look for that file in the current directory.
You can change your path all you want, but that's just fact of life.

XP improved on the command line by making file associations available.
Consequently, you could type:

html2latex.pl myfile.htm

under XP and the file will be run so long as it is somewhere in your path.
If you explicitly call the interpreter, however:

perl html2latex.pl myfile.htm

you will get the same problem you're encountering on Win98.

Matt
 
M

Matt Garrish

Matt Garrish said:
Her advice is usually wrong. Your problem is that you're invoking the
interpreter to call the script, and the interpreter does not care what
system paths you have specified. You must call your script with an
absolute or relative path if it is not in the same directory where you're
trying to invoke it. Otherwise, perl will look for that file in the
current directory. You can change your path all you want, but that's just
fact of life.

My bad, actually. I wasn't even thinking about the -S switch as I haven't
run a Win98 box in years. You might try:

perl -S html2latex.pl myfile.html

I can't guarantee it will work on win98, not having a box to test on, but it
should...

Matt
 
J

Juergen Fenn

Matt Garrish said:
perl -S html2latex.pl myfile.html

I can't guarantee it will work on win98, not having a box to test on, but it
should...

It does work indeed. :cool: Thanks a lot for helping me. This is what I
was looking for.

Thanks!
Juergen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top