From: Richard Heintze <[EMAIL PROTECTED]>
> Can somone help me make my sample program work below?
> (1) I cannot call function hello from main.pl. Why?

Because you've loaded a different Test.pm than you wanted. Rename the 
module to TestX and see.

> (2) In main, is it necessary to say $test::x? Is there
> a way to say $x instead of $test::x?

If you successfully import the variable you can use $x. See below 
though!

> (3) Why does not "starting..." ever appear?

Because you've loaded a different Test.pm than you wanted. Rename the module to TestX 
and see.

I believe Perl loaded the Test.pm that's in the core instead of your 
module.

> I have two files:
> test.pm-------------------------------
> package test;
> require Exporter;
> our @ISA = qw(Exporter);
> our @EXPORT = qw($x hello);
> my ($x) = ("testx");

This would be better written like this:

        my $x = "testx";

anyway you can only export package variables, not lexicals! If you 
plan to export the $x variable drop the "my".

> sub hello { print "hello\n"; }
> BEGIN { $Exporter::Verbose=1; print "starting...\n"; }
> 1;
> 
> main.pl-------------------------------
> use strict;
> use warnings;
> use test qw($x hello);

Try to put a
        print "\$test::x = $test::x\n";
here, before you modify the $test::x

> $test::x = "there";
> print "\$test::x = $test::x\n";
> &test::hello();

Don't use the & when calling procedures/functions.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to