in reply to Calling a class method name in a scalar using :: syntax
However, this is very different from a qualified name. A qualified name is basically "This::That::Those". They can only contain valid identifiers, which are strings that match /\A(?:[a-zA-Z_]\w*|\d*)\z/ (yes, you can have an identifier of 0 characters).my $foo = Obj->new; for (qw( create init add )) { $foo->$_(); # note -- $foo->$_ will not work, ()'s needed }
my $meth = 'meth'; $A::B::{$meth}->(25); # %A::B:: is a symbol table # $A::B::{$meth} holds the typeglob *A::B::meth # *A::B::meth->(...) is like A::B::meth(...)
Just avoid screwing with %::, since that's a symbol table.#!/usr/bin/perl use strict; @:: = qw( this program uses empty variable names ); for $:: (@::) { print $::; } # ::; looks confusing ;) open ::, ".cshrc"; print scalar <::>; # is there no end to this madness? close ::;
|
|---|