GoCool has asked for the wisdom of the Perl Monks concerning the following question:
Suppose module CGI.pm has a sub-routine named sub1 and i
"use CGI" in my perl code and create a sub-routine named sub1 not knowing that a sub-routine with the same name already exists in CGI.pm. now if i declare and define sub1 and call it in my program using this syntax:
sub1();
which one will it refer to (assuming that both sub-routines have the exact same prototype)? i don't need to fully qualify the function name with the package name as it is imported at compile time using the "use" keyword.
how do i stop this ambiguity from happening when i write a module and allow others to use my functions/subs and variables from my package?
Thanks in advance.
Gokul
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Lexical and dynamic scope confusion!
by Zaxo (Archbishop) on Mar 27, 2005 at 05:49 UTC | |
by GoCool (Scribe) on Mar 27, 2005 at 06:06 UTC | |
by Zaxo (Archbishop) on Mar 27, 2005 at 06:15 UTC | |
|
Re: Lexical and dynamic scope confusion!
by Tanktalus (Canon) on Mar 27, 2005 at 06:24 UTC | |
by tlm (Prior) on Mar 27, 2005 at 15:58 UTC | |
|
Re: Lexical and dynamic scope confusion!
by borisz (Canon) on Mar 27, 2005 at 08:25 UTC | |
by dragonchild (Archbishop) on Mar 28, 2005 at 13:53 UTC | |
|
Re: Lexical and dynamic scope confusion!
by jZed (Prior) on Mar 27, 2005 at 05:39 UTC |