Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

String To Hash Conversion

1,563 views
Skip to first unread message

Prabu Ayyappan

unread,
Apr 4, 2008, 10:04:33 AM4/4/08
to perl Beginner
Hi All,

I want to convert a string into a Hash data structure

For Example

String:
"[['aaa',{27' => '543','21' => '111','Client' => '543','chat' => '111'}]]"

Hash:
[['aaa',{27' => '543','21' => '111','Client' => '543','chat' => '111'}]

From CPAN I got a module called Convert/PerlRef2String

http://search.cpan.org/~kaili/Convert-PerlRef2String-0.03/lib/Convert/PerlRef2String.pm

But for that i want to encode the string to base64 and then want to give the string as parameter for string2perlref($string);

Is it advisable. Please help me.

Thanks,
Prabu

____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com

Gunnar Hjalmarsson

unread,
Apr 5, 2008, 1:52:41 PM4/5/08
to begi...@perl.org
Prabu Ayyappan wrote:
> I want to convert a string into a Hash data structure
>
> For Example
>
> String:
> "[['aaa',{27' => '543','21' => '111','Client' => '543','chat' => '111'}]]"
>
> Hash:
> [['aaa',{27' => '543','21' => '111','Client' => '543','chat' => '111'}]

C:\home>type test.pl
use Data::Dumper;
$string = "['aaa',{'27' => '543','21' => '111',
'Client' => '543','chat' => '111'}]";
$ref = eval $string;
print Dumper $ref;

C:\home>test.pl
$VAR1 = [


'aaa',
{
'27' => '543',
'21' => '111',
'Client' => '543',
'chat' => '111'
}

];

C:\home>

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Prabu Ayyappan

unread,
Apr 7, 2008, 2:11:33 AM4/7/08
to Gunnar Hjalmarsson, begi...@perl.org

C:\home>

Thanks a ton that helped me a lot....

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-...@perl.org
For additional commands, e-mail: beginne...@perl.org
http://learn.perl.org/

0 new messages