Reputation: 1
I am trying to write perl program to make changes in Perforce. When I run Perforce commands using P4 from the command line, those work fine but when I write "Use P4" in a perl program, it is not able to identify the P4 class. Is there any configuration I might be missing?
P.S> -Since, it is working fine from a command line, I am assuming that my path is set correctly.
This is the error which I am getting: Can't locate object method "new" via package "P4" (perhaps you forgot to load "P4"?) at perlP4.pl line 5.
This is my program:
use strict;
push ( @INC,"C:\Program Files\Perforce");
use lib "C:\Program Files\Perforce";
use P4; # a p4perl module
my $p4 = new P4;
Any help would be appreciated.
Upvotes: 0
Views: 1501
Reputation: 340
On your command prompt run the following:
perl -MP4 -e "print P4::Identify()"
If you have not installed the p4perl module you will see:
Can't locate P4.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/....
.... (snip) ....
BEGIN failed--compilation aborted.
Upvotes: 0
Reputation: 107030
I haven't used Perforce in a while, so I maybe out of date here:
The P4 module requires the Perforce C++ API library to be used, and there is quite a bit of compiled C programming with the P4 module. With Windows, much of this is already compiled (and I see you're using Windows).
Read the installation directions very carefully. Make sure you have the API libraries installed as well as the P4 module (and all of its sub-modules) installed. Since use P4;
itself doesn't throw an error, I am assuming that the Perl portion of the P4 module is installed. The problem is communicating with the P4 C++ API.
The sub new
subroutine isn't in the P4.pm
module, but is part of the P4.xs
XS package. If you have P4.pm
installed, but you don't have the API setup correctly, you will get the error you're getting.
Upvotes: 0
Reputation: 5069
P4 module is stored in a file P4.pm. Try to find this module in your system to see it is installed or not.
If it is not installed, then please install it first.
http://www.perforce.com/perforce/doc.current/manuals/p4script/02_perl.html
Upvotes: 1