Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Hagbone (Monk)
on Feb 25, 2005 at 00:07 UTC ( [id://434321]=note: print w/replies, xml ) Need Help??


in reply to Can the "#" character be passed via $ENV{QUERY_STRING} ?

Apologies, Tanktalus, about the literal interpretation issue .... the reason I've pursued this item is that I've got this very, very lightweight script that only needs the raw QUERY_STRING info to do it's thing (no parsing of values, etc.), and the only hitch is that the info being passed needs to include the # character. Firing up CGI to deal with this one item is making me feel resource greedy.

I guess I'll stick with including the few lines that substitute "#" for an alternate character passed in the Q_S.

Appears I'm at the point of beating a dead horse .... just thought there might be some way to do the deed with even less code or resources.

  • Comment on Re: Can the "#" character be passed via $ENV{QUERY_STRING} ?

Replies are listed 'Best First'.
Re^2: Can the "#" character be passed via $ENV{QUERY_STRING} ?
by mdillon (Priest) on Feb 25, 2005 at 02:35 UTC
    You don't need to load all of CGI to do this if you are taking the whole QUERY_STRING as a single value. You can use URI:Escape directly. It is an extremely lightweight module. You'll want to use uri_unescape, like so:
    use URI::Escape qw(uri_unescape); my $query_string = uri_unescape $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.
        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://434321]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found