in reply to Symbolic References
For example:
Note that if you get the value of $blaref wrong, you'll just reference (and probably create) another variable without any warning whatsoever.no strict 'refs'; $bla = "something"; $blaref = "bla"; $$blaref = "something else"; print $bla; # prints "something else"
Just about the only reason to use symbolic reference nowadays is to dynamically create named subroutines or classes (i.e. setting @{"${classname}::ISA"})
See also perldata on typeglobs. and perlmod on Symbol tablesmy $subname = "packagename::some_sub"; no strict 'refs'; # note that we use a typeglob here *$subname = sub { print "Hello from subroutine $subname"; }; packagename::some_sub();
|
|---|