CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Proper Installation and usage of modules.

 



Mr Keystrokes
Novice

Jul 11, 2017, 5:54 AM

Post #1 of 5 (1104 views)
Proper Installation and usage of modules. Can't Post

I installed a module for capturing Real numbers (http://search.cpan.org/~abigail/Regexp-Common-2017060201/lib/Regexp/Common.pm) and I've implemented it following the synopsis and examples on CPAN as such:


Code
#!/usr/bin/perl  
use strict;
use warnings;
use Regexp::Common qw /number/;

while (<>) {
/^$RE{num}{int}$/ and print "Integer\n";
/^$RE{num}{real}$/ and print "Real\n";
/^$RE{num}{real}{-base => 16}$/ and print "Hexadecimal real\n";
}

print "Enter limit: ";
chomp( my $limit = <STDIN> );
$limit = abs($limit);

open my $IN, '<', "xt_spacer_results.hairpin" or die $!;
open my $SIFTED, '>', "new_xt_spacer_results.hairpin" or die $!;

while (<$IN>){
next if /^None/;
next if /^( $RE{num}{real}{-places=>2})/ && $1 > $limit;
print $SIFTED $_;
}

close $IN;
close $SIFTED;


But I can't get it to work because as I run it, it states that it cannot find the location of:

Code
use Regexp::Common qw /number/;


So I'm wondering... Shouldn't the module be placed in the same directory as the script.pl being run? Even still it doesn't work.


Mr Keystrokes
Novice

Jul 11, 2017, 6:09 AM

Post #2 of 5 (1102 views)
Re: [Mr Keystrokes] Proper Installation and usage of modules. [In reply to] Can't Post

Okay I've since changed the use line because I don't have writing rights to the default place modules are normally kept, so I installed them somewhere I can right it and I'm using:

Code
use lib '/my/module/is/here';

So now a new problem arises... the hashes %RE require an explicit package name.
I'm sure this is covered in the module itself but maybe I'm not calling the module correctly.


BillKSmith
Veteran

Jul 11, 2017, 8:12 AM

Post #3 of 5 (1098 views)
Re: [Mr Keystrokes] Proper Installation and usage of modules. [In reply to] Can't Post

Assuming that you have installed the module correctly, the directory named in your 'use lib ...' should contain a subdirectory named 'Regexp' (case sensitive). That subdirectory should contain the module 'Common.pm' (also case sensitive). This module probably has additional requirements.

Unless you know exactly what you are doing, modules from CPAN should be installed only with a tool made for the purpose (e.g. cpan - Refer to perldoc cpan for documentation). You will be surprised by how much work it does. You have indicated that you do not have privileges to install in its default directory. I believe that tool has an option to install in a directory of your choice. If not, you will have to search for a similar tool that does.
Good Luck,
Bill


FishMonger
Veteran / Moderator

Jul 11, 2017, 8:21 AM

Post #4 of 5 (1097 views)
Re: [Mr Keystrokes] Proper Installation and usage of modules. [In reply to] Can't Post

A simple google search will give you multiple examples on installing modules in a custom location.

Here's one of them found with the google search.
Installing Local Perl Modules with CPAN - https://wiki.hpcc.msu.edu/display/Bioinfo/Installing+Local+Perl+Modules+with+CPAN

You should also look at using the local::lib module/pragma. https://metacpan.org/pod/local::lib


(This post was edited by FishMonger on Jul 11, 2017, 8:24 AM)


Mr Keystrokes
Novice

Jul 24, 2017, 12:58 PM

Post #5 of 5 (1022 views)
Re: [FishMonger] Proper Installation and usage of modules. [In reply to] Can't Post

Thank you.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives