In Perl, if a variable holds the name for another variable, how do I use the first variable to visit the other one?
For example, let
$name = \"bob\";
This is very bad practice. If you ever need to do it, it means you should refactor your code. Perhaps a hash with named keys would be better:
my %data = (
'bob' => [ 'jerk', 'perlfan' ],
);
my $name = 'bob';
print $data{ $name }->[0], "\n";
print $data{ $name }->[1], "\n";
my $stringified = join ' and ', @{ $data{ $name } };
print $stringified, "\n";