Perl module question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl module question
# 1  
Old 07-07-2007
Perl module question

Trying to get a better grip on perl module, I was testing out below script,

When I use "use Acme statement", it loads the module properly and it works.

However, when I want to test out the ' use lib ' it comes up with below error message(looks like it is able to locate but cannot read or import back the function for whatever reason??).

[root@myserver perl]# ./logtest2.module.pl
Undefined subroutine &main:Smiliepen_log called at ./logtest2.module.pl line 23.

Code:
#!/usr/bin/perl -w

use strict;

#
# Below use Acme works ; just uncomment it
#

#use Acme::Webserver::Logger;


#
#  See if you can understand and do use lib 
#

use lib '/usr/lib/perl5/site_perl/5.8.8/Acme/Webserver';
require Logger;
#require 'Logger.pl';

#use Logger;
# /usr/lib/perl5/5.8.5/Acme/Webserver

open_log("webserver.log");
write_log(1, "A basic message");
write_log(10, "A debugging message");
log_level(10);
write_log(10, "Another debugging message");

close_log();

I have both Logger.pm and Logger.pl(just in case) in
usr/lib/perl5/site_perl/5.8.8/Acme/Webserver



DB<1> print "@INC";
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.7/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8
# 2  
Old 07-07-2007
Try with "use Logger" (don't use "require Logger"), and post the error message and the content of Acme::Webserver::Logger here.
# 3  
Old 07-07-2007
Hi, using use logger works fine,

I was just trying to see from my someone's code from work to see why require was being used.

someone told me because it was from older code Perl 4?
# 4  
Old 07-08-2007
I am not sure about Perl 4, but considering Perl 5 was officially released more than 13 years ago, I see no reason to consider it anymore because many Perl 4 practices have been deprecated and pursuing them you are just asking for trouble.

Normally "require" should work. I'm not sure why you said it didn't work for you. The major difference between "require" and "use" is that "require" is a runtime instruction, while "use" is a compile-time instruction, so it is executed before the rest of the program. So, you will need to use "use lib" early in the program to adjust the @INC at compile time.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl module

I am recieiving an out of memory issue in my perl module while updating the records in the oracle table. Let me know what are the check or troubleshoot steps need to be done from my end to fix the issue. (1 Reply)
Discussion started by: ramkumar15
1 Replies

2. Shell Programming and Scripting

Perl SSH without a perl module

I'm trying to create a perl script that will do 1 SSH session, but be able to write multiple commands to the session and receive multiple outputs. I know there are modules out there like Net:SSH::Perl, but I'm not allowed to use it. I was thinking of doing something like an open3 on an ssh... (4 Replies)
Discussion started by: mrwatkin
4 Replies

3. Shell Programming and Scripting

calling perl subroutine from perl expect module

All, Is it possible to call a subroutine from the perl expect module after logging to a system that is within the same program. My situation is I need to run a logic inside a machine that I'm logging in using the expect module, the logic is also available in the same expect program. Thanks,... (5 Replies)
Discussion started by: arun_maffy
5 Replies

4. Shell Programming and Scripting

Which Perl Module to use?

Hi, I need to read an excel binary file and write the data to a text file. Is it possible using Spreadsheet-ParseExcel-0.58 ? If not, is there any module available in CPAN to do this? Thanks, Js (1 Reply)
Discussion started by: jisha
1 Replies

5. Shell Programming and Scripting

Perl Module

Hi, Please help me!! Im wondering if anyone can help me with a problem i have with some perl modules. My problem is: I'm trying to connect remote host to a unix box from a windows machine. So i'm developing an application to do this. I'm programming it in perl with tcl/tk Gui interface.... (13 Replies)
Discussion started by: Phi01
13 Replies

6. UNIX for Dummies Questions & Answers

help in writing perl module

Hi i have written a perl script which was then converted to perl module by me. it works as expected. but i have to put it on many servers so i want to build a package for it. i dont know how to do that. just to check i copied perl module in "lib" directory which is working. ( directly copied... (1 Reply)
Discussion started by: zedex
1 Replies

7. Shell Programming and Scripting

Help with Perl Module

I dont know if this is a dumb question, but I am unable to move ahead and need help - There is a perl module called Header.pm which was written by someone else. I am trying to write a simple perl script which uses a function provided by the module. The function has been exported by the module... (9 Replies)
Discussion started by: NewDeb
9 Replies

8. Shell Programming and Scripting

Perl Module Help

Hi All, I am using a perl module Win32::AdminMisc in my perl script. When i running in activestate perl v5.10.0 it shows folling error --- Can't locate loadable object for module Win32::AdminMisc in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at example.pl Please reply. ... (7 Replies)
Discussion started by: suprcool
7 Replies

9. Shell Programming and Scripting

perl module question

Couple questions on perl module.. 1)where is the best place on web where it tells you what modules can do? For example, use Text::Autoformat Where is the best place on line or via command line to find the exact capability of autoformat? 2)Is there already a perl module to read *.cap... (1 Reply)
Discussion started by: convenientstore
1 Replies

10. Shell Programming and Scripting

Replace Perl Module name in all Perl scripts

I want to replace a Perl module name in all my Perl Scripts in the cgi-bin directory. How is it possible? I have the following statement in my scripts use myUtil; I want to change it to use myUtil777; Regards, Rahul (2 Replies)
Discussion started by: rahulrathod
2 Replies
Login or Register to Ask a Question