|< 1 2 >| | 13 Einträge, 2 Seiten |
msg=1&msg=2&msg=hot
@ids = CGI::param('id');
%args = CGI::Vars();
%args = ( id => [34, 12] );
1
2
3
4
5
6
7
use Data::Dumper;
use CGI::Carp qw/fatalsToBrowser/;
# yada yada
my %args = CGI::Vars();
die Dumper \%args;
1
2
3
[Wed Sep 6 00:24:19 2006] perlt.pl: $VAR1 = {
[Wed Sep 6 00:24:19 2006] perlt.pl: 'hallo' => 'hm pff'
[Wed Sep 6 00:24:19 2006] perlt.pl: };
hallo => 'hallo du test"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
use Data::Dumper;
my $cgi = CGI->new();
print $cgi->header(type => "text/plain");
my %vars = $cgi->Vars();
print Dumper(\%vars),"\n\n";
my @tests = split /\0/,$vars{test};
print Dumper(\@tests);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Many people want to fetch the entire parameter list as a hash in
which the keys are the names of the CGI parameters, and the values are
the parameters' values. The Vars() method does this. Called in a scalar
context, it returns the parameter list as a tied hash reference. Changing a
key changes the value of the parameter in the underlying CGI parameter
list. Called in a list context, it returns the parameter list as an ordinary
hash. This allows you to read the contents of the parameter list, but not to
change it.
When using this, the thing you must watch out for are multivalued CGI
parameters. Because a hash cannot distinguish between scalar and list
context, multivalued parameters will be returned as a packed string,
separated by the "\0" (null) character. You must split this packed string in
order to get at the individual values. This is the convention introduced
long ago by Steve Brenner in his cgi-lib.pl module for Perl version 4.
|< 1 2 >| | 13 Einträge, 2 Seiten |