• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Installing CPAN module in Windows

 
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I learn to program Perl in Windows. When I download a CPAN module, where do I have to put it so the perl interpeter can use it?

One more thing: The executable file of perl is located in the following path: D:\Perl\bin\perl.exe. As a result, if I want to execute a perl file, I have to put the file that I wrote in this library, and execute it from this library. I tried to use Shebang ("#!D:/Perl/bin/perl.exe -T -w") at the top of the file and put the file at another directory, but it didn't work out. Any ideas?
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shebang doesn't work in a Windows command prompt. Add D:\Perl\bin to your PATH.

The easiest way (I think) to install CPAN is to use the program call "cpan". It should be in D:\Perl\bin. Try cpan install <name_of_module>. To find out where Perl looks for modules, type this at a command line:



@INC is like a PATH for Perl modules. Usually one of the first paths has "site" in it. This is where you would manually put your modules, but try the "cpan" program first.
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I opened command window and typed "set PATH=%PATH%;C:\Perl\bin\perl.exe" and now I can run perl code from any directory.

 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One little question: I installed CPAN. Does it mean that I have all the modules included in CPAN?
 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Josh Abraham wrote:One little question: I installed CPAN. Does it mean that I have all the modules included in CPAN?



No, it means that you can run the CPAN module (or script) that easily installs modules. See if "cpan" from the command line works. If not, try perl -MCPAN -e shell.
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks. And how do I run the scripts that install a certain module? maybe the question should be: "suppose I want to install a certain module, how do I find its installation script?"

 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cpan will install it for. If you want to install MY_MOD, just type cpan MY_MOD at the command line.
 
lowercase baba
Posts: 13013
66
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Josh Abraham wrote:I opened command window and typed "set PATH=%PATH%;C:\Perl\bin\perl.exe" and now I can run perl code from any directory.


This will probably only work until you close that window. If you want a more permanent fix, you need to edit your environment variables so they apply to ALL command windows.

cpan is a script for installing cpan modules. it takes an argument of the module name you want to install. (that is, if I am remembering right).

I tend to use strawberry perl on my PC, as it made installing the modules easier. It even comes with a c compiler to use as needed.
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to write GUI in perl so I need Tk module. Therefore, I downloaded Tk by typing "cpan Tk" and the module was downloaded.
The I wrote the following perl file:



and executed it.

Then, I got the following message:
"Can't locate Tk.pm in @INC (you may need to install the Tk module)
(@INC contain s: C:/Perl64/site/lib C:/Perl64/lib .) at file.pl line 1. BEGIN failed--compilation aborted at file.pl line 1."

I don't understand why. I downloaded this module by using cpan command. What is the problem here?

 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suspect that the Tk module didn't install. Both Tk and Wx require a C compiler. Do you know if you have one? You can try typing where gcc at the command line and see if it finds anything. If not, I would try installing MinWG. You may still have to change your PATH environment variable to point to the C compiler (gcc).
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm looking at the command window and I see that the last lines after the run of cpan Tk are:

"windres' is not recognized as an internal or external command, operable program or batch file. dmake.exe: Error code 129, while making 'tkres.o' dmake.exe: Error code 255, while making 'pTk\libpTk.a' SREZIC/Tk-804.032.tar.gz C:\Perl64\site\bin\dmake.exe -- NOT OK"


I typed "where gcc" and I got: "C:\Perl64\site\bin\gcc.exe". I added this path to PATH environment variable.
Still, I can't execute the file.


 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think your distribution of Perl has everything needed to install this module. Are you married to this distribution? You might want to try Strawberry Perl. You will still have to change your PATH environment, but I think it will compile Tk for you. At least it did for me.
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
change PATH to what?
 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, for instance, if you install Strawberry Perl in the default directory, you would need C:\Strawberry\perl\bin and C:\Strawberry\c\bin. Your Perl64 paths can come out of the PATH.

You change your PATH environment variable (In Windows 7) with:

Control Panel -> System and Security -> System. Click Advanced System Settings (on the left). Push the Environment Variables button.
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did that.
installed Tk again and no change :-(
 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you installed Strawberry Perl and tried to install the Tk module, and you got the same error about windres? If you do a where windres it doesn't find anything? You installed Perl in C:\Strawberry and you have C:\Straeberry\c\bin in the PATH?

I noticed that you had Perl in D:\Perl64 before. Do you need to change C:\Strawberry to D:\Strawberry?

If none of that rings a bell, type PATH at the command line, copy and paste it into a post. Then cd into D:\Strawberry and do a dir and post that.
 
Josh Abraham
Ranch Hand
Posts: 38
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've made some changes.

Now, I have C:\Strawberry and C:\Perl64 only on C disk.
I do "where wonders" and it doesn't find anything. You're right.


PATH=C:\Perl64\site\bin;C:\Perl64\bin;D:\Perl\site\bin;D:\Perl\bin;C:\Program Fi
les\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Fil
es\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\Syste
m32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Wind
ows Live\Shared;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\P
rogram Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL
Server\100\DTS\Binn\;D:\R2011a Run\runtime\win64;D:\R2011a Run\bin;D:\ZipGenius
6\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Mi
crosoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\Windows Kits\8.0\
Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Bin
n\ ; "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\BI
N";C:\Program Files\VDownloader;D:\MySQL Utilities\;D:\MySQL Utilities\Doctrine
extensions for PHP\;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;D:\Ghdl\Bi
n;C:\Perl64\site\bin\;C:\Strawberry\perl\bin;C:\Strawberry\c\bin




C:\Strawberry>dir
Volume in drive C is OS
Volume Serial Number is FE23-CCC3

Directory of C:\Strawberry

01/28/2015 10:02 PM <DIR> .
01/28/2015 10:02 PM <DIR> ..
01/28/2015 10:01 PM <DIR> c
01/28/2015 10:01 PM <DIR> cpan
09/15/2014 05:33 PM 12,446 DISTRIBUTIONS.t
01/28/2015 10:02 PM <DIR> licenses
01/28/2015 10:01 PM <DIR> perl
01/28/2015 10:02 PM 2,119 README.txt
01/28/2015 10:02 PM 24,974 relocation.txt
01/28/2015 10:02 PM <DIR> win32
3 File(s) 39,539 bytes
7 Dir(s) 83,051,917,312 bytes free




 
Knute Snortum
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is very unusual. Try this: from the command line:

cd C:\Strawberry\c\bin\
dir windres.exe

If the file windres.exe is not displayed, then I'm stuck. If it *is* displayed, then something is wrong with your PATH.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic