
santhosh_89
Novice
Jul 30, 2009, 8:46 PM
Post #1 of 5
(1844 views)
|
|
How to make array references from scalar value
|
Can't Post
|
|
I want to make array/hash references from scalar value. I used eval method to convert to perl structure. I Used character inside the scalar value .it will not be single quote in value field as ( $a="a,b,{perl=>guru}").So the eval method returns null value.If i use single quote in all the values.Eval will return the correct value.Why the single quote is needed inside the scalar value (my $a="'a','b',{'perl'=>'monk'}" ),already The value is with in double quotes. otherwise anyone knows any cpan modules to solve this problem.The problems is if the string found [,{,I need to change that value to hash({) or array([) references. The eval is given null value. my $a="[a,b,{perl=>monk}]"; my $b=eval $a; print Dumper($b); Following coding is working fine. my $a="['a','b',{'perl'=>'monk'}]"; my $b=eval $a; print Dumper($b);
|