Rectangle 27 7

The nonstandard paths in @INC (e.g. /usr/local/packages, perl_remote etc) indicate to me that this is a custom perl installed for a specific purpose probably with reduced functionality to prevent mischief.

installation - Why does my Perl program complain "Can't locate URI.pm ...

perl installation module
Rectangle 27 8

Possibly you do not have URI installed. It might not be saved anywhere on your machine, or it might be "installed" in a location.

  • If it's just not installed, then you need to install it from CPAN.
  • If you have it saved to your machine, you just need to let the system know where to get it.

If you have to install it from CPAN, you likely need administrator privileges to put it in the listed directories. But CPAN will allow you to install it to a user directory, so you can still install it.

So if you can't install the module in the directories listed in @INC, then there are the various ways.

installation - Why does my Perl program complain "Can't locate URI.pm ...

perl installation module
Rectangle 27 5

You don't have Time::Piece installed for /usr/bin/perl, so install it.

/usr/bin/perl -MCPAN -e install Time::Piece

You don't have DBI installed for /usr/local/bin/perl, so install it.

/usr/local/bin/perl -MCPAN -e install DBI

One more thing, in the Perl program, you have to manually tell it where to look. So I had to put this code line: use lib "/home/el/perl5/lib/perl5/x86_64-linux-thread-multi"; before the invocation of: use Time::Piece; in my perl program. I was able to find which path to use by running the command: locate Piece.pm

@Eric Leschinski, Your comment has nothing to do with this thread. You apparently installed a module into the non-default directory (and thus had to tell Perl where to look for it), but that's not what the OP is doing.

I understand now. The command you provided /usr/bin/perl -MCPAN -e install Time::Piece picks the wrong default installation directory and my perl couldn't find it. The user has to install it in the right place or else perl won't find it.

solaris - cannot run perl program: Can't locate Time/Piece.pm in @INC ...

perl solaris perl-module solaris-10
Rectangle 27 3

package Packet;
package Syslog;
package UDP;

If so, you need to load each one of them separately using

use Packet;
use Syslog;
use UDP;

On the other hand, if you have one file in Packet/Syslog/UDP.pm then it has to have package Packet::Syslog::UDP; at the top and you'd load it using

use Packet::Syslog::UDP;

Oh, and BTW, if this is up to you, I'd strongly recommend using a company or project specific module name-space. So instead of 'Packet.pm' I'd create a file called 'Company/Packet.pm' which would have package Company::Packet; at the top and I'd load it with use Company::Packet; Otherwise you'll easily bump into modules with the same name.

Some articles that might shed more light on the subject:

Perl, Can't locate Packet/UDP/Syslog.pm in @INC | custom modules - Sta...

perl
Rectangle 27 1

The array @INC contains the list of places to look for Perl scripts to be evaluated. Your script will not run because it is not in the @INC list. Either:

  • Put the script in one of the @INC locations; or
  • Add the location of the file to the $PATH environmental variable; or
  • Specify the full path of the script when you are calling it.

The problem can also be that the URI.pm module is not installed (liburi-perl package on my ubuntu, but i dont know the module's name on solaris)

Well, not installed or installed in a directory not in @INC.

installation - Why does my Perl program complain "Can't locate URI.pm ...

perl installation module
Rectangle 27 2

Yikes! That tutorial is crap. Perhaps at one time it was cutting-edge Perl, but it is way out of date. The module Mysql.pm was deprecated way back in 2006! You should be using DBI instead.

Also, you should include the statements use strict; and use warnings; at the top of every Perl script you ever write. If you find a tutorial that doesn't include those directives in example scripts, stop reading and look for a new tutorial immediately.*

The following shows how to connect to a MySQL database using the DBI module and print out the results of a SELECT statement. See the documentation for details.

use strict;
use warnings;
use 5.010;

use DBI;

my $dsn = "DBI:mysql:test;localhost";
my $user = 'user';
my $pass = 'pass';

my $dbh = DBI->connect($dsn, $user, $pass, {
    PrintError => 0,
    RaiseError => 1
});

my $statement = <<'SQL';
    SELECT foo
    FROM bar
SQL

my $sth = $dbh->prepare($statement);
$sth->execute;

while (my $row = $sth->fetch) {
    say "@$row";
}

$dbh->disconnect;

* Short code snippets don't need these but if an example script includes a shebang line (e.g. #!/usr/bin/perl), it had better have strict and warnings, too.

Strawberry Perl/Eclipse/EPIC - Can't locate MySql.pm in @INC (you may ...

mysql eclipse perl strawberry-perl
Rectangle 27 3

I believe CPAN.pm likes to call a lot of sub-processes for various tasks, and these end up starting new perls, which will not inherit your -I flag. Instead, try setting a PERL5LIB environment variable, e.g.

PERL5LIB='/v1/data/site_perl' perl -MCPAN -e 'install Log::Dispatch'

Another strategy to consider is to simply build a complete Perl installation in your local directory -- then use that perl's CPAN utilities. They will already have all your own paths built-in. This is the way I tend to do it.

perl - Can't locate in @INC during CPAN dependency install performed n...

perl install cpan
Rectangle 27 2

I used -I to add my non-root lib to @INC. Once the CPAN got to the primary module, it couldn't find the required recently installed modules because that instance of @INC didn't contain my directory. I didn't try setting PERL5LIB, which worked. local::lib is not installed on that machine, but soon will be! Thanks for the info.

perl - Can't locate in @INC during CPAN dependency install performed n...

perl install cpan
Rectangle 27 7

You need to install CGI::Session. Best way is to use your OS package manager. In Fedora/Redhat or similar it would be yum install perl-CGI-Session. In Debian-based, apt-get install libcgi-session-perl. If you want to install with cpan shell, paste somewhere whole log with errors and publish link to it here.

I tried to install through "yum" but getting the following error: [root@localhost /]# yum install perl-CGI-Session Loading "installonlyn" plugin Setting up Install Process Setting up repositories Could not retrieve mirrorlist mirrors.fedoraproject.org/mirrorlist?repo=core-6&arch=i386 error was [Errno 4] IOError: <urlopen error (101, 'Network is unreachable')> Error: Cannot find a valid baseurl for repo: core

The key part looks to be "IOError: <urlopen error (101, 'Network is unreachable')>". Are you sure that the machine you're attempting this on has working internet access?

ping mirrors.fedoraproject.org

Do you have a firewall? It sounds like you could either have a firewall/proxy issue or a internal server DNS issue.

perl - Why does my CGI script complain "Can't locate CGI/Session.pm in...

perl cgi
Rectangle 27 14

In addition to the locations listed above, the OS X version of Perl also has two more ways:

How is Perl's @INC constructed? (aka What are all the ways of affectin...

perl perl-module
Rectangle 27 8

Subclassing DBI has to be done just right to work correctly. Read Subclassing the DBI carefully and properly set RootClass (or explicitly call connect on your root class with @ISA set to DBI). Make sure you have WebDB::st subclassing DBI::st and a WebDB::db class subclassing DBI::db (even if there are no methods being overridden). No need to rebless.

Avoid using base; it has some unfortunate behavior that has led to its deprecation, particularly when used with classes that are not in a file of their own. Either explicitly set @ISA or use the newer parent pragma:

package WebDB;
use parent 'DBI';
...
package WebDB::db;
use parent -norequire => 'DBI::db';
...
package WebDB::st;
use parent -norequire => 'DBI::st';
...

perl - Can't locate object method via package - Stack Overflow

perl oop subclass dbi
Rectangle 27 5

First: the error means that your script wants to call the method strftime which shall be defined in a special package. Looking at your script, the following happens:

  • you are calling localtime which is a method and returns the current time as a string, e.g. "Thu Jun 20 01:14:01 2013"
  • you try to call the method strftime defined in a package (module) with the name returned by localtime. That doesn't work.

strftime is defined in POSIX and takes >1 parameters: the format and the time. You probably want to call:

use POSIX;

my $date = POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime);
my $time = POSIX::strftime('%H:%M:%S', localtime);
use POSIX;

my @localtime = localtime;
my $date = POSIX::strftime('%Y-%m-%d %H:%M:%S', @localtime);
my $time = POSIX::strftime('%H:%M:%S', @localtime);

since localtime returns an array which should be the input to strftime.

ok, sorry. You have to import strftime. Looks like it depends on perl version. Worked for me in a quick test. I edit my post.

I edited my post. Either write use POSIX qw(strftime) at the beginning or use POSIX::strftime(...) in the code.

perl - Can't locate object method "strftime" via package - Stack Overf...

perl datetime
Rectangle 27 10

Perl is case-sensitive. www::Mechanize is not the same as WWW::Mechanize (the latter has capital W's).

You're loading (upper-case) WWW::Mechanize and then trying to create an object of class (lower-case) www::Mechanize, which doesn't exist.

my $mech = WWW::Mechanize->new();

instead of

my $mech = new WWW::Mechanize();

(But that wasn't the cause of your problem.)

I appreciate your help now i can able to run my script . just wanted to know about follow_link() what it will do exactly

perl - Can't locate object method "new" via package "www::Mechanize" (...

perl www-mechanize
Rectangle 27 10

Perl is case-sensitive. www::Mechanize is not the same as WWW::Mechanize (the latter has capital W's).

You're loading (upper-case) WWW::Mechanize and then trying to create an object of class (lower-case) www::Mechanize, which doesn't exist.

my $mech = WWW::Mechanize->new();

instead of

my $mech = new WWW::Mechanize();

(But that wasn't the cause of your problem.)

I appreciate your help now i can able to run my script . just wanted to know about follow_link() what it will do exactly

perl - Can't locate object method "new" via package "www::Mechanize" (...

perl www-mechanize
Rectangle 27 3

Close @Jim Garrison, but I think it's a missing use Time::Piece issue.

@Rudra - try adding that to the top of your script and see if it does the job.

If you want it to work in Test.pm, you have to use it there too. A use in the main package just imports into the main package, not into all other loaded modules. And since the question didn't mention Time::Piece (a module I never heard of until now) I think the other answers were reasonable in that they are actually correct in the absence of overridden core functions!

Actually, it's a core module. Frequently overlooked though.

perl - Can't locate object method "strftime" via package - Stack Overf...

perl datetime
Rectangle 27 4

$ git svn
Can't locate SVN/Core.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.10.0
/usr/lib/perl5/5.10.0/i486-linux-thread-multi
/usr/lib/perl5/5.10.0
/usr/lib/perl5/site_perl/5.10.0/i486-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.10.0/i486-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.10.0
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl .) at
/usr/libexec/git-core/git-svn line 29.

because I don't have Subversion Perl bindings installed. Try installing them and running the command again.

I've also seen this with the Perl bindings installed in a different location than Git expected; corrected with a symlink.

git-svn not a git command? - Stack Overflow

svn git git-svn
Rectangle 27 4

$ git svn
Can't locate SVN/Core.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.10.0
/usr/lib/perl5/5.10.0/i486-linux-thread-multi
/usr/lib/perl5/5.10.0
/usr/lib/perl5/site_perl/5.10.0/i486-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.10.0/i486-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.10.0
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl .) at
/usr/libexec/git-core/git-svn line 29.

because I don't have Subversion Perl bindings installed. Try installing them and running the command again.

I've also seen this with the Perl bindings installed in a different location than Git expected; corrected with a symlink.

git-svn not a git command? - Stack Overflow

svn git git-svn
Rectangle 27 2

The @INC variable contains a list of directories to in which to look for modules. It starts with the first entry and then moves on to next if it doesn't find the request module. @INC has a default value that created when perl is compiled, but you can can change it with the PERL5LIB environment variable, the lib pragma, and directly manipulating the @INC array in a BEGIN block:

#!/usr/bin/perl

BEGIN {
    @INC = (); #no modules can be found
}

use strict; #error: Can't locate strict.pm in @INC (@INC contains:)

This is how a co-worker has told me he solves this, by adding his local module directory as the first @INC entry.

How do I choose a package name for a custom Perl module that does not ...

perl module naming-conventions cpan
Rectangle 27 2

The first line stands for shebang. It basically tells the program where Perl interpreter is located since Perl is interpreted language. On Linux you can type in terminal:

whereis perl

which will give you exact location of it. Usually it's inside /usr/bin/perl. This means that you want to make shebang regarding to /usr/bin/perl

#! /usr/bin/perl

use strict;
use warnings;
use v5.10.1;
.
.
.

What should I use for a Perl script's shebang line? - Stack Overflow

perl shebang
Rectangle 27 2

The first line stands for shebang. It basically tells the program where Perl interpreter is located since Perl is interpreted language. On Linux you can type in terminal:

whereis perl

which will give you exact location of it. Usually it's inside /usr/bin/perl. This means that you want to make shebang regarding to /usr/bin/perl

#! /usr/bin/perl

use strict;
use warnings;
use v5.10.1;
.
.
.

What should I use for a Perl script's shebang line? - Stack Overflow

perl shebang