Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Hashes and Cookies (or more to the point, strings)

by bikeNomad (Priest)
on Jul 19, 2001 at 19:23 UTC ( [id://98108]=note: print w/replies, xml ) Need Help??


in reply to Hashes and Cookies (or more to the point, strings)

The problem is that the assignment isn't parsed as it would be in your source text. The fastest thing to do is to split it:

my $cookie = 'name1,value1,name2,value2'; my %hash = split(',', $cookie);

Or you can use string eval on your quoted string (but why?):

my $cookie = '("Name1","Value1","Name2","Value2")'; my %hash = eval $cookie;

update: But don't do that. As crazyinsomniac points out, it's not a really good idea to eval cookie contents...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://98108]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-24 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found