in reply to calling functions with same names but in different modules depending on user input
For more info, see perlboot.{ package A; sub just_print { my $class = shift; # extra parameter must be accounted for print "In A: @_\n"; } } { package B; sub just_print { my $class = shift; # extra parameter must be accounted for print "In B: @_\n"; } } # back to package main: print "A or B: "; chomp(my $selector = <STDIN>); $selector =~ /^[AB]$/ or die "I said A, or B!"; $selector->just_print(1..10); # prints 1..10
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: calling functions with same names but in different modules depending on user input
by Anonymous Monk on May 06, 2004 at 18:18 UTC |