We're through the looking glass now, folks. Perl 6 is still bleeding-edge alpha-ware but it will run, mostly, on the "pugs" interpretter. Well, at least enough to get a feel for the new syntax. It feels weird.
#!/usr/bin/pugs
my %q;
for %ENV<QUERY_STRING>.split('&') {
my ($n, $v) = .split('=').map: &decode;
%q{$n}.push($v);
}
print "content-type: text/html\n\n";
for %q.keys { say "$_ => "~%q{$_}.join(', ')~'<br>' }
sub decode(my $input is copy) {
$input ~~ s:Perl5:g/\+/ /;
$input ~~ s:Perl5:g/%(..)/{chr(:16($0))}/;
return $input;
}Things are different in Perl 6 Land. Verrry different. For starters, all that trouble you went though figuring out when to use an @, or a $ won't matter here: arrays are always prefixed with @. Always. Even when you are accessing a single value. Same goes for % and hashes.
Oh, and the arrow dereference operator is gone. Now we dot. As Larry says, "just like every other modern object oriented language." The tilde has stepped up to take the dot's place for concatenation, and two tildes act as the regex binding operator.
This little example should not be used to handle CGI parameters, though that's what it mostly does. As I said, it's just an example. And weird. It's also very, very weird.
