in reply to Re: Accessing variables in a runtime-loaded module
in thread Accessing variables in a runtime-loaded module

Ah, but I'm trying to use this as plugin:

package Foo; use vars( qw (@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION) ); require Exporter; @ISA = qw( Exporter ); @EXPORT = qw( $description ); @EXPORT_OK = (); %EXPORT_TAGS = (); $VERSION = "0.1"; my $description="Plugin I am!" 1;

So Foo::description is a scalar, not a subroutine. And when trying to access the variable content perl says that it's undefined.

Replies are listed 'Best First'.
Re^3: Accessing variables in a runtime-loaded module
by rev_1318 (Chaplain) on Jun 09, 2005 at 14:22 UTC
    lexical variables can never be accessed from outside your package/file. You need a package global variable, eg. our $description to be able to access it.
    See perlmod for more on packages and modules.

    Paul

      You don't need a package variable: you need an acccessor method. Global variables suck. :)

      my $description = 'foo'; sub description { $description }
      --
      brian d foy <brian@stonehenge.com>