* Michael Mathews <[EMAIL PROTECTED]> [2006-05-28 11:40]:
> #!/usr/bin/pugs
>
> say "content-type: text/html\n\n";
> my %q = ();
> my @q = split '&', %ENV.{'QUERY_STRING'};
> for (@q) {
> my ($n, $v) = split '=', $_;
>
> # TODO: deal with URI encoding
> # similar to perl5: s/%(..)/pack("c",hex($1))/ge;
>
> #TODO: handle multiple values and same key
>
> %q.{$n} = $v;
> }
>
> for (%q.keys) { say $_, " => ", %q.{$_}, "<br>"; }
Flying blindly (ie. no Pugs installed):
my @q = split /&/, %ENV<QUERY_STRING>
==> map { split /=/, $_, 2 }
==> map { $_ # TODO: deal with URI encoding };
say "Content-type: text/plain\n\n";
for @q -> $key, $val { say "$key => $val" } }
I’d like to know if there’s a way to write `split` as a method
call, though, in which case the explicit `$_` could go away by
merely invoking the `split` method on the topic, something like
this maybe:
map { .split /=/, 2 }
I’d also like to know if there’s a way to use the `->` pointy
with `map` in order to walk lists several elements at a times and
to assign name(s) for the iterator(s) instead of having to use
the topic.
Regards,
--
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;