in reply to Re^2: access to sub of package
in thread access to sub of package

The B module is part of the standard distribution and doesn't have a usage sub, so yeah you'll get an error. Use a better example module name (e.g. Foo or the like) and you'll get better results.

Replies are listed 'Best First'.
Re^4: access to sub of package
by jeanluca (Deacon) on Feb 28, 2006 at 15:09 UTC
    just one other thing. The difference with the example, and the situation I've here is that I've the package name inside a variable, like: $var = "B" ;Now this doesn't work:
    $var::usage() ;
    But this does
    $var->usage
    Do you know why this is ?

    Thanks
    Luca

      Because the later is a method lookup (which allows a scalar containing a package name to be used) while the former is a syntax error (you've named a scalar $usage in the package var, then you're trying to call it as a function). If you need to call something in a dynamically determined package you'll need to use eval or something like { no strict 'refs'; &{"${var}::usage"}( ) }).

Re^4: access to sub of package
by jeanluca (Deacon) on Feb 28, 2006 at 15:04 UTC
    Yep, thnks, I noticed that when I add use lib '.'; it works too!!

    Luca