Just copy and paste the command below into your command prompt:
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC'
If used with grep, you can easily search through the list to confirm if your already have a certain perl module installed on your server or not! for example am looking for a Perl module named "Time::HiRes", so i run the command below:
perl -MFile::Find=find -MFile::Spec::Functions -Tlwe 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC' | grep Time
/usr/lib64/perl5/Time/Piece.pm
/usr/lib64/perl5/Time/HiRes.pm
/usr/lib64/perl5/Time/Seconds.pm
/usr/share/perl5/Net/Time.pm
/usr/share/perl5/CPAN/FirstTime.pm
/usr/share/perl5/Time/Local.pm
/usr/share/perl5/Time/tm.pm
/usr/share/perl5/Time/localtime.pm
/usr/share/perl5/Time/gmtime.pm
“It has become appallingly obvious that our technology has exceeded our humanity.” Albert Einstein
Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts
Wednesday, November 19, 2014
Thursday, December 6, 2012
Working with Perl & Tk to create GUIs - Setting up the environment
Today I set out on a mission to spice up my Perl scripting skills by adding GUIs in my scripts and the best way to archive this, is by using perl’s Tk module. Here is how my story unfolded before i finally got it to work.
Operating System: Ubuntu 10.10 - the Maverick Meerkat
Checking if perl is in my environment PATH:
root@marc# which perl
/usr/bin/perl
The above output tells me that i have perl running on my machine otherwise it would return something like “command not found” or an empty string!
Checking the version of perl am running:
root@marc# perl -v
This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi
(with 40 registered patches, see perl -V for more detail)
Then I tried a test script to check if my default perl installation already has a Tk module but no luck! which means I had to install the perl Tk module, there are two ways:
1. Download the archive and manually install perl-Tk:
Download Link: CPAN
change to the dir where you saved your download. Extract the archive: #gunzip Tk-804.028.tar.gz
# tar -xvf Tk-804.028.tar
change to the Tk dir: #cd Tk-804.028
#perl Makefile.PL
#make
#make test
#make install
2. Use cpan to install Tk (this is the easier and recommended option)
Make sure you are root otherwise the installation script will have permission issues!
#sudo su
#cpan
cpan[1]>
// if you are on a direct internet connection, cpan will automatically download the required modules and the dependencies from CPAN using ftp.
//if you computer is behind a proxy that requires authentication, then you have to modify the cpan config. this is how you add the proxy configuration in cpan.
cpan[1]> o conf init /proxy/
<ftp_proxy>
Your ftp_proxy? [ftp://10.192.1.101:3128/]
//cpan tries to automatically detect the proxy as show above, enter
<http_proxy>
Your http_proxy? [http://10.192.1.101:3128/]
//enter
<no_proxy>
Your no_proxy? []
//for IPs that you want excluded from the proxy config, you can leave this blank and enter
If your proxy is an authenticating proxy, you can store your username
permanently. If you do not want that, just press RETURN. You will then
be asked for your username in every future session.
Your proxy user id? [joshua]
//enter
Your password for the authenticating proxy can also be stored
permanently on disk. If this violates your security policy, just press
RETURN. You will then be asked for the password in every future
session.
CPAN: Term::ReadKey loaded ok (v2.30)
Your proxy password?
//enter
Please remember to call 'o conf commit' to make the config permanent!
cpan[2]>install Tk
//cpan will download and install TK
//during the installation test phase, you will see a lot of pop ups, that means that your Tk library is being built and it’s an exciting moment :-)
Test your installation, try to run a script that calls the Tk module ( use Tk; ). if the script runs without errors then you are good to go. Your environment it set to run perl with Tk.
In the next posts, i will be sharing my experience with perl + Tk GUIs, this was basically about setting up the development environment and i hope you did the same.
for windows, you don’t have to go through this hustle, just go to ActiveState and download perl for your Windows OS, it comes with all the libraries including Tk.
Download Link: ActiveState
Operating System: Ubuntu 10.10 - the Maverick Meerkat
Checking if perl is in my environment PATH:
root@marc# which perl
/usr/bin/perl
The above output tells me that i have perl running on my machine otherwise it would return something like “command not found” or an empty string!
Checking the version of perl am running:
root@marc# perl -v
This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi
(with 40 registered patches, see perl -V for more detail)
Then I tried a test script to check if my default perl installation already has a Tk module but no luck! which means I had to install the perl Tk module, there are two ways:
1. Download the archive and manually install perl-Tk:
Download Link: CPAN
![]() |
Perl scripting with Tk to add Graphical User Interfaces |
# tar -xvf Tk-804.028.tar
change to the Tk dir: #cd Tk-804.028
#perl Makefile.PL
#make
#make test
#make install
2. Use cpan to install Tk (this is the easier and recommended option)
Make sure you are root otherwise the installation script will have permission issues!
#sudo su
#cpan
cpan[1]>
// if you are on a direct internet connection, cpan will automatically download the required modules and the dependencies from CPAN using ftp.
//if you computer is behind a proxy that requires authentication, then you have to modify the cpan config. this is how you add the proxy configuration in cpan.
cpan[1]> o conf init /proxy/
<ftp_proxy>
Your ftp_proxy? [ftp://10.192.1.101:3128/]
//cpan tries to automatically detect the proxy as show above, enter
<http_proxy>
Your http_proxy? [http://10.192.1.101:3128/]
//enter
<no_proxy>
Your no_proxy? []
//for IPs that you want excluded from the proxy config, you can leave this blank and enter
If your proxy is an authenticating proxy, you can store your username
permanently. If you do not want that, just press RETURN. You will then
be asked for your username in every future session.
Your proxy user id? [joshua]
//enter
Your password for the authenticating proxy can also be stored
permanently on disk. If this violates your security policy, just press
RETURN. You will then be asked for the password in every future
session.
CPAN: Term::ReadKey loaded ok (v2.30)
Your proxy password?
//enter
Please remember to call 'o conf commit' to make the config permanent!
cpan[2]>install Tk
//cpan will download and install TK
//during the installation test phase, you will see a lot of pop ups, that means that your Tk library is being built and it’s an exciting moment :-)
Test your installation, try to run a script that calls the Tk module ( use Tk; ). if the script runs without errors then you are good to go. Your environment it set to run perl with Tk.
In the next posts, i will be sharing my experience with perl + Tk GUIs, this was basically about setting up the development environment and i hope you did the same.
for windows, you don’t have to go through this hustle, just go to ActiveState and download perl for your Windows OS, it comes with all the libraries including Tk.
Download Link: ActiveState
![]() |
Active State Perl |
Subscribe to:
Posts (Atom)