# Can't locate Tk.pm in @INC



## SeaHag (Feb 25, 2010)

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


```
#!/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?


----------



## sixtydoses (Feb 25, 2010)

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.


```
[od@sixtydoses ~/.cpan]$ ls build/Tk-804.028-2t9Zhu | grep Tk.pm
Tk.pm
```


----------



## Alt (Feb 25, 2010)

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)

```
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 =)


----------



## SirDice (Feb 25, 2010)

Do you actually have Tk installed? Check with `# pkg_version -v`.


----------



## SeaHag (Feb 26, 2010)

pkg_version -v shows:


```
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?


----------



## Alt (Feb 26, 2010)

Can you read all posts not just last ? =)


----------

