Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Converting a hash element into an array

by dorward (Curate)
on Jan 19, 2009 at 11:19 UTC ( #737263=note: print w/replies, xml ) Need Help??

in reply to Converting a hash element into an array

I wrote the following in JavaScript a few years ago. The logic should be the same in Perl, but I'll leave porting it as an exercise for the reader.
var query_string = {}; var query =; var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(pair[1]); } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://737263]
[stevieb]: yeah. This is my build/test software that manipulates perlbrew/ berrybrew, and runs all unit tests of a project against all installed versions, including testing a dist against all of it's current revdeps. A lot of tests it runs for itself:)
[stevieb]: testing the test build system, essentially

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-03-26 22:10 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (315 votes). Check out past polls.