Author:
erics, August 4th, 2019
I wanted to call a sub-routine based on a variable in Perl, like this:
|
our $role = 'master'; &$role; |
but it failed because of use strict:
|
Can't use string ("master") as a subroutine ref while "strict refs" in use at /opt/continuent/tungsten/tools/tungsten_find_orphaned line 213. |
To enable using a variable as a reference, simply specify that to Perl:
|
use strict no strict "refs"; |
Categories: How-To's, Technology Tags: de-reference, dereference, howto, no strict, perl, Reference, Strict, Subroutine, tips, Variable
|
No comments
Author:
erics, February 2nd, 2012
Inside class “yourClassA” calling “yourClassB”:
|
class yourClassA { $classObject = new yourClassB; $classObject->setClass($this); } |
Inside class “yourClassB” getting the call from “yourClassA”:
|
class yourClassB { public function setClass($object = NULL) { if(is_object($object) and $object instanceof yourClassA) { $this->RefToClassA = $object; $this->yourVar = $RefToClassA->otherVar; // etc, etc, etc... } } } |
Categories: How-To's, Technology Tags: Class, Classes, Function, Object, Object Oriented, OO, php, Reference, Var, Variable
|
No comments