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 , August 19th, 2011
A small step forwards in understanding how Perl handles hashes as arguments. This biggest difference is that the first way “slurps” in ALL passed values in @_ into the %args hash. The second (cooler) way, pulls in the arguments hash as a single scalar variable, allowing multiple variables to be passed via @_, if you […]
Categories: How-To's , Technology Tags: Argument , Hash , howto , perl , Subroutine , tips
| No comments
Author:
erics , May 5th, 2011
my $ value = $ self -> myFunction ( ) -> { 'result' } ;
Where :
sub myFunction {
my $ self = shift ;
. . . code here . . .
return {
'status' = > 0 ,
'result' = > 'Hello World' ,
} ;
}
Categories: How-To's , Technology Tags: Hash , howto , perl , Return , Subroutine
| No comments