Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Pass arguments in URL

by BrowserUk (Patriarch)
on Aug 23, 2010 at 14:39 UTC ( [id://856719]=note: print w/replies, xml ) Need Help??


in reply to Pass arguments in URL

Storable freeze produces a binary string that may contain a whole bunch of characters that would be incompatible with passing as part of a url. You might try url encoding the results of freeze, but I wouldn't like to rely upon that.

It would be better to hexify the frozen data before adding it as a part of your url.

Given oneScript like this:

#! perl -slw use strict; use Storable qw[ freeze ]; my %params = ( period => 30, vid => 'xyz1234', person => 'homer', ); my $encoded = unpack 'H*', freeze \%params; system qq[otherScript.pl ?arg=$encoded];

Calling another script like this:

#! perl -slw use strict; use Data::Dump qw[ pp ]; use Storable qw[ thaw ]; my( $name, $payload ) = split '=', $ARGV[ 0 ]; my $params = thaw pack 'H*', $payload; pp $params;

The result is:

c:\test>oneScript { period => 30, person => "homer", vid => "xyz1234" }

Log In?
Username:
Password:

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

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

    No recent polls found