G
Gundala Viswanath
Hi,
This code below tries to convert
the string in newick format into the corresponding
data structure (Array of Array).
But somehow the EVAL function doesn't work
as expected. What's wrong with my code here?
__BEGIN__
use Data:
umper;
use Carp;
my $str = "(foo,(bar,qux))"; #Newick format
print "$str\n";
my $ar = conv_newick2aoa($str);
print Dumper $ar ;
sub conv_newick2aoa {
my $nstr_in = shift;
my $nstr = $nstr_in;
for ($nstr) {
s/\\/\\\\/g;
s/'/\\'/g;
s/\(/['/g;
s/\)/']/g;
s/,/','/g;
}
return eval{$nstr};
}
__END__
Why it doesn't give this output instead:
$VAR1 = [
'foo',
[
'bar',
'qux'
]
];
Regards,
Gundala Viswanath
Jakarta-INDONESIA
This code below tries to convert
the string in newick format into the corresponding
data structure (Array of Array).
But somehow the EVAL function doesn't work
as expected. What's wrong with my code here?
__BEGIN__
use Data:
use Carp;
my $str = "(foo,(bar,qux))"; #Newick format
print "$str\n";
my $ar = conv_newick2aoa($str);
print Dumper $ar ;
sub conv_newick2aoa {
my $nstr_in = shift;
my $nstr = $nstr_in;
for ($nstr) {
s/\\/\\\\/g;
s/'/\\'/g;
s/\(/['/g;
s/\)/']/g;
s/,/','/g;
}
return eval{$nstr};
}
__END__
Why it doesn't give this output instead:
$VAR1 = [
'foo',
[
'bar',
'qux'
]
];
Regards,
Gundala Viswanath
Jakarta-INDONESIA