Re: can you pass an array in a form in Perl
- From: "nobull67@xxxxxxxxx" <nobull67@xxxxxxxxx>
- Date: 27 Sep 2006 10:31:38 -0700
John wrote:
Is the following possible in Perl?
print "<form>";
print "<input type='hidden' name='cities' value='@industries'>";
print </form>";
I want to pass an array as a hidden value.
The values of HTML fields are plain text (this as nothing to do with
Perl). A Perl array has structure (this as nothing to do with HTML).
To store something with structure in a plain text string you need to
serialize it in some way (this as nothing to do with Perl or HTML).
If you have a Perl array the elements of which are plain text and which
you know won't contain a given character you can simply use join() and
split().
If you want to store aribtrary Perl structures in plain text fields the
usual approach is to use Storeable and MIME::Base64. (And optionally
some sort or compression and encryption).
use Storable qw( freeze thaw );
use MIME::Base64;
use Compress::Zlib qw( compress uncompress );
require Crypt::CBC;
my $cipher = Crypt::CBC->new($ENV{CRYPTO_KEY},'Blowfish');
sub encode {
encode_base64(compress($cipher->encrypt(freeze(shift))),'');
}
sub decode {
my $state = shift;
return unless $state;
thaw($cipher->decrypt(uncompress(decode_base64($state))));
}
.
- References:
- can you pass an array in a form in Perl
- From: John
- can you pass an array in a form in Perl
- Prev by Date: Re: --compare current date file with previous day
- Next by Date: Re: can you pass an array in a form in Perl
- Previous by thread: can you pass an array in a form in Perl
- Next by thread: Re: can you pass an array in a form in Perl
- Index(es):
Relevant Pages
|
|