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.
In reply to Re: Spliting on Key/value pairs
by allolex
in thread Spliting on Key/value pairs
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |