Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Monks, I bow to your buddha nature.... I ran into an interesting problem today. I am recieveing information from a cookie that is formatted in the following way:
name1,value1,name2,value2....etc.
this looks like a hash to me so I attempted to copy the cookie string to a variable like so:
my $rep= new CGI; my $cookie = $rep->cookie("cookiename");
so now $cookie has one long string with all the data separated by commas. Now, I append ()'s and quotes in all the right places, and I have a string that says something like this:
("Name1","Value1","Name2","Value2")
Setting my hash equal to this never worked right, I suspect that it has something to with the fact that the equal operator does not take the string as a literal and instead put the whole string in the first key. Is there any way to have a hash look at a string in the literal sense, or do I have to split the string into an array and hash it from there? Thanks

Anyway, no drug, not even alcohol, causes the fundamental ills of society. If we're looking for the source of our troubles, we shouldn't test people for drugs, we should test them for stupidity, ignorance, greed and love of power.

--P. J. O'Rourke

In reply to Hashes and Cookies (or more to the point, strings) by Snuggle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found