Mr_Micawber has asked for the wisdom of the Perl Monks concerning the following question:
I've been experimenting with using interpolated strings to define hashes. I'm curious why the variation defining %kv below works. There's something about the colon, which I think is a pair constructor (?) and the square brackets that I'm not getting.
#!/usr/bin/perl6 use v6; my ($hkey, $hval ) = <somekey someval>; # simple form: # my %kv = $hkey, $hval; # works my %kv = :[$hkey],$hval; # works # my %kv = :$hkey,$hval; # error # my %kv = :{$hkey},$hval; # _block83 someval say %kv; # somekey someval
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl 6, defining a hash with interpolated string
by molecules (Monk) on Aug 04, 2010 at 17:43 UTC | |
by Mr_Micawber (Beadle) on Aug 04, 2010 at 19:12 UTC | |
by molecules (Monk) on Aug 04, 2010 at 20:32 UTC | |
by Mr_Micawber (Beadle) on Aug 04, 2010 at 21:23 UTC | |
by molecules (Monk) on Aug 05, 2010 at 11:53 UTC | |
|