[Israel.pm] package/sub ambiguity
semuelf at 012.net.il
Sun Jun 1 12:25:29 PDT 2008
Here is what I had:
a package (object) named Repeater and a sub named Repeater.
when I tried to create a new Repeater, I did:
$r = Repeater->create(...);
and got unexpected results.
After thinking a bit about it, I found out that instead of running the
create method in the Repeater package, it instead run the Repeater sub,
and tried to run create on the result.
meaning, I actually got:
$r = (&Repeater())->create(...);
A way to resolve that was to write:
$r = "Repeater"->create(...);
a probably better way to resolve this is not creating packages and subs
with the same names.
Any advice from the community? I actually liked the sub-package name
More information about the Perl