yikes, i have to resort to them whenever i want to have "generic" logic that deals with a multitude of routines.
i use symbolic references for :
object methods
dispatch tables
and in most unit test scripts
If you have a better alternative; i'll consider it!
####
package <>;
our $scalarMethods;
@{ $scalarMethods } = qw( name );
foreach my $attributeScalar ( @{ $scalarMethods } ) {
no strict "refs";
*$attributeScalar = sub {
my $subName = $package . "::$attributeScalar";
if ($VRB) { print " $subName \n"; }
my ($self) = shift;
if (@_) { $self->{$attributeScalar} = shift; }
return $self->{$attributeScalar};
}
}
##
##
for ( $ndx=0; $ndx<=0; $ndx++ ) {
no strict 'refs';
($kgDATA,$pmDATA) = &{ "cktTmplt_utils::$SUB" }($ndx );
##
##
# are package variables accessible ?
no strict "refs";
foreach my $pkg ( @{ $filePackages } ) {
for ( my $i=0; $i<=1; $i++ ) {
${ $pkg . "::VRB" } = $i;
is( $i, ${ $pkg . "::VRB" }, "GLBL VAR : VRB" );
${ $pkg . "::TST" } = $i;
is( $i, ${ $pkg . "::TST" }, "GLBL VAR : TST" );
}
${ $pkg . "::VRB" } = 1; # no STDOUT durings tests
${ $pkg . "::TST" } = 1; # return data and don't execute
}
use strict "refs";