in reply to Using functions from their own package
Yes, exactly. To elaborate on Anonymous Monk’s answer:
12:41 >perl -Mstrict -wE "package myPackage; sub function1 { myPackage +::function2('Hi!'); } sub function2 { say qq[@_]; } function1();" Hi! 12:41 >perl -Mstrict -wE "package myPackage; sub function1 { function2 +('Hi!'); } sub function2 { say qq[@_]; } function1();" Hi! 12:41 >perl -Mstrict -wE "package myPackage; sub function1 { myPackage +->function2('Hi!'); } sub function2 { say qq[@_]; } function1();" myPackage Hi! 12:41 >
Within the package, prepending myPackage:: to a function name is merely redundant. But prepending myPackage-> changes the behaviour: it passes the package name to the function as the first argument.
Hope that helps,
Athanasius <°(((>< contra mundum
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using functions from their own package
by Anonymous Monk on Oct 15, 2012 at 04:01 UTC |