954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

substitute a string

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...

localp
Junior Poster
191 posts since Apr 2008
Reputation Points: 1
Solved Threads: 3
 

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;
KevinADC
Posting Shark
921 posts since Mar 2006
Reputation Points: 246
Solved Threads: 67
 

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 !!

localp
Junior Poster
191 posts since Apr 2008
Reputation Points: 1
Solved Threads: 3
 

actually there was an error in this line:

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

should have been:

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

KevinADC
Posting Shark
921 posts since Mar 2006
Reputation Points: 246
Solved Threads: 67
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You