[CTS] Re: Perl string substitution question

  • From: John Durham <john.modec@xxxxxxxxxx>
  • To: computertalkshop@xxxxxxxxxxxxx
  • Date: Wed, 17 Sep 2003 11:17:13 +1200

I'm still working in the dark on this, John. Can I please have a more detailed description of what the parts of that statement do, so I understand how to work it into the script? Even better, I might be able to work specific substitutions with it. Up until now I hav been trying:
$string =~ s/PATTERN/REPLACEMENT/ge
but this doesn't seem to work with string variables.


John Madden wrote:

I'm trying to create a script that uses data from a URL. Part of the
data is a multi word command containing spaces. The spaces arrive in the
form %20 and I'm attempting to replace them with real ones. The bit of
code relevant to this is below:



There's a perl command that takes care of the query string / post data conversions. Check this out:

$data =~ s/%(..)/pack("c",hex($1))/ge;

That'll take care of the whole set of characters.

John

--
Regards, John Durham <http://modecideas.com/contact.html?sig>
ICQ number 112663246
Fax/Phone 64 4 5286786
Award winning web site at http://modecideas.com?sig
Order my latest e-book at http://modecideas.com/dmaxhits.htm?sig
PC-HELPERS list subscribe/unsub at http://modecideas.com/discuss.htm?sig
Good advice is like good paint- it only works if applied.




--------------------------------------------------------------------------- Computer Talk Shop http://www.computertalkshop.com Un-subscribe/Vacation, http://www.computertalkshop.com/list_options.htm

List HowTo: http://www.computertalkshop.com/faq.htm

To join Computer Talk Shop's off topic list, please goto:
http://computertalkshop.com/other_cts_lists.htm
---------------------------------------------------------------------------

Other related posts: