Hello monks,
I've question about dispatching to a module's method when two modules have the same method name. The following is a example of the coding I'm trying to achieve:I would like the name "main" to be dispatched to Module1's "main" method and "another_page" to be dispatched to Module2's "main". The easy way out is to give Module2's "main" a different name. But if there's a conflict of method names, is there a way to unambiguously call a module's method?package Module1; use strict; use Exporter qw(import); our @EXPORT = qw(main); sub main { do_something(); } 1; package Module2; use strict; use Exporter qw(import); our @EXPORT = qw(main); sub main { do_something2(); } 1; script.pl my $query = get_param('page') || 'main'; my %pages = ( main => \&main, # to go to Module1 main another_page => \&main, #to go to Module2 main );
Hope my question is clear and many thanks in advance.
In reply to Dispatcher to module's method by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |