CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
How to make array references from scalar value

 



santhosh_89
Novice

Jul 30, 2009, 8:46 PM

Post #1 of 5 (2366 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);


KevinR
Veteran


Jul 30, 2009, 8:58 PM

Post #2 of 5 (2364 views)
Re: [santhosh_89] How to make array references from scalar value [In reply to] Can't Post

please start using the code tags and post formatted code. And please try and use proper grammar.
-------------------------------------------------


santhosh_89
Novice

Jul 30, 2009, 9:07 PM

Post #3 of 5 (2362 views)
Re: [KevinR] How to make array references from scalar value [In reply to] Can't Post

Nothing wrong in this.please check your grammar and previous query's funny result.go and check it.


santhosh_89
Novice

Jul 30, 2009, 9:08 PM

Post #4 of 5 (2361 views)
Re: [santhosh_89] How to make array references from scalar value [In reply to] Can't Post

Hello kevinR if you know the correct and understandable answer put it in the form,otherwise don't try it.


(This post was edited by santhosh_89 on Jul 30, 2009, 9:09 PM)


KevinR
Veteran


Jul 30, 2009, 9:13 PM

Post #5 of 5 (2358 views)
Re: [santhosh_89] How to make array references from scalar value [In reply to] Can't Post

You want an understandable answer? Try posting an understandable question. And put code in code tags.

Smile Tongue Crazy
-------------------------------------------------


(This post was edited by KevinR on Jul 30, 2009, 9:14 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives