K
knohr
I come from a perl background. I have gotten in the habit of using
references to variables instead of specifically calling said variable/
class/whatever.
Basically, I am wondering how I would translate the following into
ruby.
example 1:
sub my_sub
{
$choice = shift;
$choices="this|that|foo|bar";
if ( $choice =~ m/($choices)/ ) {&$choice}
else {die "some witty msg"}
}
example 2:
$this = 'var_name';
$var_name = 'i want this to print';
print $$var_name . "\n";
thanks
references to variables instead of specifically calling said variable/
class/whatever.
Basically, I am wondering how I would translate the following into
ruby.
example 1:
sub my_sub
{
$choice = shift;
$choices="this|that|foo|bar";
if ( $choice =~ m/($choices)/ ) {&$choice}
else {die "some witty msg"}
}
example 2:
$this = 'var_name';
$var_name = 'i want this to print';
print $$var_name . "\n";
thanks