Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Spliting on Key/value pairs

by allolex (Curate)
on May 11, 2009 at 10:26 UTC ( #763212=note: print w/ replies, xml ) Need Help??


in reply to Spliting on Key/value pairs

You could do something like this:

my $string = '&keyname=value&keyname2=value2'; # eliminate the first ampersand for cleaner output $string =~ s/^&//; foreach ( split /&/, $string ) { printf "Key: %s, Value: %s\n", split /=/; }

I'd also look on CPAN for something that parses URL queries.

-d.


Comment on Re: Spliting on Key/value pairs
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2014-12-28 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls