in reply to Using Exporter module

Not exporting a sub doesn't prevent it from being called. Exporting simply allows you to do sub() instead of doing Module::sub(). Functions which aren't imported can still be called

Perl doesn't provide a means of making a function uncallable from outside of a namespace. There are ways of making it harder to call a function, but most programmers are satisfied to signal that a function is for private use by prepending an underscore (_) to its name.

Update: By the way, it's totally useless to export methods unless they can also be called as functions. It looks to me like you don't need Exporter at all.

Replies are listed 'Best First'.
Re^2: Using Exporter module
by perlCrazy (Monk) on Jul 18, 2007 at 19:51 UTC
    Thanks for reply.
    What is the way to stop exporting all functions in calling program ? is there any way or I am just trying to do things that is not possible.

      Exporting doesn't mean what you think it does, at least not in Perl. To export is to remove the requirement to use a fully qualified name.

      What you really want, it seems, is to make a function uncallable from outside of {something}. (A namespace? Code that originated from a certain file?) Perl doesn't provide any direct means of doing that. Perl considers this a documentation issue. If a user of your module disreguards your documentation and call a function he shouldn't, it's his own foot he's shooting.

      Many programmers prepend an underscore (_) to the name of their private subs/methods as an indication that they shouldn't be called.

        I think we can acheive this by creating private method. and not call like $self->_method() Inside module
        if we call the private method like this: _method($self,arguments.) and if we try to call this subroutine outside then this will thorw an error.