i am reading a url and inthat i have an array that has stored the value of a string as follows

address=no+3%2C+oxford+street

in this wat i want is to display the address as 

"no 3 oxford street"

some one please give me the code to write this as the output i want...

Recommended Answers

All 3 Replies

There are other ways, but here is one:

my $string = 'address=no+3%2C+oxford+street';
(my $key,$value) = split(/=/,$string);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 
print $value;

There are other ways, but here is one:

my $string = 'address=no+3%2C+oxford+street';
(my $key,$value) = split(/=/,$string);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 
print $value;

it worked thanks !!

actually there was an error in this line:

(my $key,$value) = split(/=/,$string);

should have been:

my($key,$value) = split(/=/,$string);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.