[Brisbane-pm] Messing with Modules 2

Martin Jacobs martin_jacobs at optusnet.com.au
Fri Mar 16 22:14:12 PDT 2007


Thanks Jacinta and Damien,

Yup, I missed the capitals. Just to make sure, I copied and pasted  
from http://www.unix.org.ua/orelly/perl/prog3/ch11_02.htm (which I  
didn't know existed until yesterday). I also tried Jacinta's qw  
suggestion.

Same problem, though.

This call works...

use input::Simple_Billycan_2_Stage qw(water_export);
Simple_Billycan_2_Stage::water_export();
		
But this one doesn't...

use input::Simple_Billycan_2_Stage qw(water_export);
water_export();
		
Here's the error message from the second call...

Undefined subroutine &main::water_export called at perrmoss.pl line  
379, <RF> line 21.

Here's the module...

package Simple_Billycan_2_Stage;
require      Exporter;

our @ISA       = qw(Exporter);
our @EXPORT    = qw(water_export);    # Symbols to be exported by  
default
our @EXPORT_OK = qw($weight);    # Symbols to be exported on request
our $VERSION   = 1.00;         # Version number

### Include your variables and functions here

sub water_export { print "One-hump dromedary\n" }

$weight = 1024;

1;

I also have the following at the start of the main program...

#!/usr/local/bin/perl
use warnings;
use strict;
use Time::Local;
use lib;

I tried the use lib after reading Chapter 11 of 'Programming Perl',  
though it does not make a difference to the problem described above.

I might be clutching at straws, but I wonder if this has something to  
do with file paths. I'm working on Mac OSX10.4.

The main program, PERRMOSS is...
user/martin/PERRMOSS/Perl/PERRMOSS.pl

The module is...
user/martin/PERRMOSS/Perl/input/Simple_Billycan_2_Stage.pm

And the perl stuff is in...
system/library/perl/5.8.6/

(makes me wonder how the #!/usr/local/bin/perl line works! - I guess  
I need it for windows systems)

One more thing. Because I'm going to define my modules with one sub- 
routine each, should I put the name of the sub-routine in our  
@EXPORT_OK = qw($function_name); ?


Regards,
Martin
Visit my website...
http://web.mac.com/martin_jacobs1


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/brisbane-pm/attachments/20070317/cce03050/attachment.html 


More information about the Brisbane-pm mailing list