On Mon, May 29, 2006 at 05:28:53PM -0700, Ovid wrote: > > Now that I read what I wrote, I guess that might have sounded a bit > annoying for me to mention that I would change things but then not > mention what I would change. > > Much of the changes would be stylistic in nature, but not all (I'm > running this against Pugs and assuming it's correct). Here's my take on > it: > > #!/usr/bin/pugs > > print "content-type: text/html\n\n"; > my %q; > > for %ENV<QUERY_STRING>.split('&') -> $nv { > my ($n, $v) = $nv.split('='); > decode($n); > decode($v); > > %q{$n} = [] unless %q.exists($n); > # %q{$n} //= []; # first try, but I don't think it's correct > %q{$n}.push($v);
Why not let this auto-vivify? E.g.: $ pugs -e 'my %e; %e<a>.push: 1,2,3; say %e;' a 1 2 3 I'm kind of surprised that worked, with the OO syntax. But is it considered bad style? I use it constantly in perl5... those constant tests for existence are so obnoxious in other languages, though I like Ruby's approach. joel