
Kanji
User
Jul 7, 2000, 4:54 PM
Post #2 of 7
(564 views)
|
|
Re: Passing arguments into a perl-module...
[In reply to]
|
Can't Post
|
|
mikerobb-- You don't provide anywhere near enough (like what errors you're getting) or consistent (where the heck did b.pl come from?) information for you anyone to tell you what you're doing wrong, but you need to ... Make sure b.pm had a defined package namespace (package b;) and returns a true value (1;). In a.pl, when you call functions in b.pm, make sure you use two colons, not one (b::inc($var);) as in your example. Here's all that put together ... <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> #!/usr/bin/perl -wT ## ## This is a.pl ## use strict; # BEGIN { unshift @INC, "." } if you prefer use lib qw( . ); use b; my $variable = "Hello"; b::inc($variable);</pre><HR></BLOCKQUOTE> <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> package b; sub inc { my $parm = shift; print "$parm World!\n; } 1;</pre><HR></BLOCKQUOTE>
|