I have such script: (Script.pl)
#!/usr/bin/perl
use strict;
use warnings;
use encoding 'utf-8';
use FindBin;
use lib "$FindBin::Bin/lib";
use TwitterModule;
use IO::Prompt;
# Read keys from file
open KEYS, "<keys.txt" or die $!;
my ($ckey, $csecret, $atocken, $asecret) = <KEYS>;
# Auth
my $nt = TwitterModule::auth($ckey, $csecret, $atocken, $asecret) ;
# Other code skipped.
and such module: (lib/TwitterModule.pm)
package TwitterModule;
use strict;
use warnings;
use utf8;
use encoding 'utf8';
use base 'Exporter';
use Net::Twitter;
BEGIN {
use Exporter();
our $VERSION = '0.01b';
our @EXPORT_OK = qw(&auth);
our %EXPORT_TAGS = (
'functions' => [ qw(&auth) ]
);
# add all the other ":class" tags to the ":all" class, deleting duplicates
my %seen;
push @{$EXPORT_TAGS{all}},
grep {!$seen{$_}++} @{$EXPORT_TAGS{$_}} foreach keys %EXPORT_TAGS;
}
### Common variables ###
# Make connection
sub auth {
my ($ckey, $csecret, $atocken, $asecret) = @_;
my $cn = Net::Twitter->new(
traits => [qw/Oauth API::REST/],
consumer_key => $ckey,
consumer_secret => $csecret,
access_tocken => $atocken,
access_token_secret => $asecret
);
return $cn;
}
# Other code skipped
# return true
1
Then, i execute my script and get it: “Can’t locate Net/Twitter/Role/Oauth.pm in @INC (@INC contains: /home/rasmi/work/my_project/lib /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl .) at /usr/share/perl5/vendor_perl/Module/Runtime.pm line 205, line 4. at /home/rasmi/work/my_project/lib/TwitterModule.pm line 6”
I have installed Net::Twitter and all necessary utils and tested it at the two machines. If i used Net::Twitter without modules, in one script, everything works fine. File /usr/share/perl5/vendor_perl/Net/Twitter/Role/Oauth.pm exist.
I am very surprised by this behavior and would be very grateful for the help.
It looks like it’s spelled Net::Twitter::Role::OAuth–note the capital ‘A’. You’re probably on a case-sensitive filesystem.
Correct the line in your
authsubroutine:And it will likely start working.