Take the 2-minute tour ×

I have such script: (Script.pl)

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;

    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}},

### 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

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.

share|improve this question
add comment

closed as too localized by Alexander, joran, hjpotter92, jadarnel27, gnat Mar 4 '13 at 6:08


1 Answer

up vote 4 down vote accepted

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 auth subroutine:


And it will likely start working.

share|improve this answer
+1 Nice catch, Josh. –  TLP Dec 27 '11 at 22:59
I got burned yesterday with a one-liner on an OS X (case-insensitive) system because I was spelling MIME::Base64 'Mime::Base64'. The .pm was loading, but there was of course nothing in the Mime:: namespace. So it was easy to spot this :) –  Josh Y. Dec 27 '11 at 23:05
Capitalization is very easy to misremember. –  TLP Dec 27 '11 at 23:15
add comment
