How to convert query string in hash in perl -


i have query string this:

id=60087888;jid=16471827;from=advance;action=apply 

or can :

id=60087888&jid=16471827&from=advance&action=apply 

now want create hash have key id , value

i have done this

my %in;       $buffer = 'resid=60087888;jobid=16471827;from=advance;action=apply';       @pairs = split(/=/, $buffer);       foreach $pair (@pairs){            ($name, $value) = split(/=/, $pair);            $in{$name} = $value;        }  print %in; 

but issue in query string can semin colon or & how can please me

check answer:

my %in;       $buffer = 'resid=60087888;jobid=16471827;from=advance;action=apply';       @pairs = split(/[&,;]/, $buffer);       foreach $pair (@pairs){            ($name, $value) = split(/=/, $pair);            $in{$name} = $value;        } delete $in{resid}; print keys %in; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -