The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl DBI/DBD Module -in cygwin jambesh Shell Programming and Scripting 3 10-20-2007 02:38 PM
Can I use a Perl Module without installing it? jjinno Shell Programming and Scripting 1 08-29-2007 02:55 PM
perl module question convenientstore Shell Programming and Scripting 1 05-22-2007 08:25 PM
Replace Perl Module name in all Perl scripts rahulrathod Shell Programming and Scripting 2 12-02-2005 01:00 AM
Writing perl module jo_aze Shell Programming and Scripting 4 08-06-2003 12:10 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-07-2007
hankooknara hankooknara is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 80
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:pen_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 (permalink)  
Old 07-07-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
Try with "use Logger" (don't use "require Logger"), and post the error message and the content of Acme::Webserver::Logger here.
  #3 (permalink)  
Old 07-07-2007
hankooknara hankooknara is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 80
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 (permalink)  
Old 07-08-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0