Richard Heintze wrote:
I apologize if I'm posting this twice. I assume that it did not go out to the group because I did not get any responses and the folks at [EMAIL PROTECTED] have been extremely helpful in the past.
Can somone help me make my sample program work below? (1) I cannot call function hello from main.pl. Why?
Are you getting an error like this 'Can't locate test.pm in @INC ...'? If so you will have to add the directory where test.pm is located to @INC One way (the recommended way) to do this is use lib '<directory where test.pm is located>';
(2) In main, is it necessary to say $test::x? Is there a way to say $x instead of $test::x?
Declare $x as our $x instead of my $x
(3) Why does not "starting..." ever appear? thanks,
I don't think test.pm was loaded, try the use lib option and see what happens
Read through these docs perldoc perlmod perldoc perlmodlib perldoc perlmodstyle
Siegfried
I have two files: test.pm------------------------------- package test; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw($x hello);
It is recommended to use @EXPORT_OK instead of @EXPORT. Read through the above docs and you will know the reason and loads of other info for writing safe modules.
my ($x) = ("testx"); sub hello { print "hello\n"; } BEGIN { $Exporter::Verbose=1; print "starting...\n"; } 1;
main.pl------------------------------- use strict; use warnings; use test qw($x hello); $test::x = "there"; print "\$test::x = $test::x\n"; &test::hello();
__________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
