On Wed, 2008-09-03 at 23:51 -0700, Gundala Viswanath wrote:
> 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;
         s/'\[/[/g;
         s/\]'/]/g;
>     }
> 
>     return eval{$nstr};
     my $ref = eval $nstr;
     die $@ if $@
     return $ref;
> }

The code `eval { $var }` returns the contents of $var.  The code `eval
$var` executes the code in $var.  See `perldoc -f eval` for details.


-- 
Just my 0.00000002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."
        Cross Time Cafe

"Perl is the duct tape of the Internet."
        Hassan Schroeder, Sun's first webmaster


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to