in reply to Re: Re: Re: Re: Sharing the scalar love?
in thread Sharing the scalar love?

I misunderstood then. Do you mean like...

S.pm....

package S; use strict; use warnings; require Exporter; @S::ISA = qw(Exporter); @S::EXPORT = qw($x); our $x = 1; 1;

And t.pl again..

use strict; use warnings; use S; print $x; print "\n";
I hate this since it imports into the user's symbol table.. which I hate. I prefer my first answer since it's less prone to mucking up the user space.

Note: someone reply to my bad usage of @S::ISA. Someone prolly knows of a better way of doing this with strict on :)


Play that funky music white boy..

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Sharing the scalar love?
by Joost (Canon) on Dec 22, 2003 at 21:51 UTC
    Note: someone reply to my bad usage of @S::ISA. Someone prolly knows of a better way of doing this with strict on :)
    Howabout (for perl 5.6.0 and up):
    package S; our @ISA = qw(Exporter);
    Or use vars qw(@ISA) for older perls.

    At least it doesn't make you type the package name, which is error prone, since it creates a new package if you spell it wrong.

    Joost.

      In order to use an unqualified "$x" in the caller, I had to code the "S" (S.pm) module thus (The examples provided above gave Syntax errors):
      package S; use strict; use warnings; use Exporter; #"require" works too, but use is more std. our @ISA = qw(Exporter); our @EXPORT = qw($x); our $x = 999; 1;
      "When you are faced with a dilemma, might as well make dilemmanade. "
    A reply falls below the community's threshold of quality. You may see it by logging in.