Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Can the "#" character be passed via $ENV{QUERY_STRING} ?

by BUU (Prior)
on Feb 25, 2005 at 06:46 UTC ( #434393=note: print w/replies, xml ) Need Help??


in reply to Re^2: Can the "#" character be passed via $ENV{QUERY_STRING} ?
in thread Can the "#" character be passed via $ENV{QUERY_STRING} ?

Just to note, uri_unescape is functionally:  s/%(\d\d)/chr $1/eg; if you don't even want to load the module.

Replies are listed 'Best First'.
Re^4: Can the "#" character be passed via $ENV{QUERY_STRING} ?
by mdillon (Priest) on Feb 25, 2005 at 14:42 UTC
    I think that should be:
    s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg
    In fact, that's pretty much exactly what's in URI::Escape, except that the module also handles scalar v. list context and multiple arguments. Using uri_unescape still seems preferable to me, since the resource overhead of using the module is basically nil and the mnemonic benefit of seeing uri_unescape instead of a regex is considerable.
      You know, you're completely correct, and that mostly proves your point about using a module. I theoretially knew what the proper code should be, but I wasn't paying attention and wrote something that was broken and didn't even think about it, the module would have been much easier.
        You are both correct. s/%(\d\d)/chr $1/eg will do fine if all you care about are encoded #'s (but then, you might as well use the faster and shorter s/%23/#/g). But if you want to be more general, use what mdillon states.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://434393]
help
Chatterbox?
[karlgoethebier]: Discipulus: worst band you heard in your live: https://www. youtube.com/watch? v=582FrJaDMOk
[karlgoethebier]: ...ever...
[karlgoethebier]: ...probably to much Panzerschokolade

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2017-07-25 10:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (369 votes). Check out past polls.