Can't locate Tk.pm in @INC

I'm trying to run this simple Perl script and getting this error.

Code:
#!/usr/local/bin/perl

use Tk;
# Main Window
my $mw = new MainWindow;
my $label = $mw -> Label(-text=>"Hello World") -> pack();
my $button = $mw -> Button(-text => "Quit", 
		-command => sub { exit })
	-> pack();
MainLoop;

Please excuse my noobishness but I'm learning Perl and what is a Perl module?
 
I am no Perl expert, but I remember installing something that requires all this Tk stuff, which I grabbed from http://www.cpan.org/ . But all of these were done on a linux platform though.

Not sure if you need this x11-toolkits/p5-Tcl-Tk installed, or just by running cpan -i Tk will solve the problem. I have not tried this myself on FreeBSD.

cpan()


Edit: Woops I tried it, and had tons of popups lol.. and lots of errors too.

And more edit: I didn't proceed with the make install. From the build directory there's Tk.pm, so probably it's just me who didn't do it properly.

Code:
[od@sixtydoses ~/.cpan]$ ls build/Tk-804.028-2t9Zhu | grep Tk.pm
Tk.pm
 
SeaHag said:
I'm trying to run this simple Perl script and getting this error.
For simple install perl module do this under root (as sixtydoses said)
Code:
cpan -i Tk
Do not download .tgz from cpan / compile it=) Its linux way

SeaHag said:
Please excuse my noobishness but I'm learning Perl and what is a Perl module?
(Near)Everything you declare like 'use Tk;' or 'use MODULE;' is connecting module to ur program. Modules add functionality.

P.S. And yes, you writing x11 program, so you must run it under x11 =)
 
Do you actually have Tk installed? Check with # pkg_version -v.
 
pkg_version -v shows:

Code:
tk-8.4.19_2,2                       =   up-to-date with port
tk-8.5.8                            =   up-to-date with port

So I guess Perl modules are like importing libraries in other languages. It seems it can't find this one. Where is it looking for it? Do I need to setup some library path?
 
Back
Top