(Thanks to Ilya Zakharevich <ilya@math.ohio-state.edu> for pointing out that perl code comes in a variety of flavors and some code requires more work than others to install. Hence I have expanded this topic and will refer to three distinct categories here: Scripts Modules and Extensions:)
Other things you do not want to forget when trying to run a perl script include giving yourself permission to do so, e.g.:
chmod u+x newscriptnameYou also want to be sure your DISPLAY environment variable is set up properly when attempting to run a perl/Tk script. You may also need to look at the xhost(1) or the xauth(1) man pages for setting up your X-display properly.
If you are still experiencing difficulty check to be sure that extraneous /newsgroup|e-mail|HTML headers|footers|markup//; are not in the file and that you have on hand all that is requireed or useed by the script (if not you may need to install a module - or even a perl4 style lib.pl file).
#!/usr/bin/perl -w BEGIN { @INC = ("$ENV{'PWD'}",@INC); } use Tk; use Foo;or
#!/usr/bin/perl -w use lib $ENV{PWD}; use Tk; use Foo;Another approach is to set either the PERLLIB or PERL5LIB environment variable from your shell. This method allows invoking the test script from within a number of different directories without having to edit a hard coded use lib or push(@INC,".") kind of statement within the script. Yet another way to do it is with the -I switch on the command line like so:
perl -Ipath/to/Foo -e fooscriptname
After a successful test; if you are a system administrator, or have root priveleges, or are modifying your own copy of perl; then copy it to the perl5/Tk directory. Depending on how the module was written it should be possible to use it either with the use Tk; statement itself or with an explicit use Tk::Foo; (for module perl5/Tk/Foo.pm).
perl Makefile.PLYou may now run make on the resultant Makefile - but the details of this process are module dependent and should be documented in a README or an INSTALL file. A very standard perl extension requires 4 (or 5 if making static) standard commands to make and install:
perl Makefile.PL make make test make installIf you have the appropriate CPAN and FTP modules already installed you can retrieve a module from CPAN and carry out all of the above steps with a perl one-liner like this:
perl -MCPAN -e 'install "Foo"'
Previous | Return to table of contents | Next