in reply to Re: printing hashes
in thread printing hashes

Perl 6 will interpolate spacetab-separated pairs, one per line, though the restrictions on interpolating arrays and hashes are tightened a bit to avoid accidental interpolation of email addresses and printf formats. You have to do something like:
say "Array is @array[]"; say "Array is {@array}"; say "Hash is %hash{}"; say "Hash is {%hash}";
Only scalars interpolate without some kind of bracketing.

The space-separated form was chosen to make it easy to split on whitespace, but it's expected that most hash interpolations will in fact specify some more explicit format:

say "Hash is %hash.as('%s => %s', ', ')";

Replies are listed 'Best First'.
Re^3: printing hashes
by Zaxo (Archbishop) on May 07, 2005 at 01:54 UTC

    Looks like pugs does most of this:

    $ pugs -e'my @array=1..5;say "Array is @array[]";' Array is 1 2 3 4 5 $ pugs -e'my @array=1..5;say "Array is {@array}";' Array is 1 2 3 4 5 $ pugs -e'my %hash;%hash{"a".."c"}=1..3;say "Hash is %hash{}"' Hash is a 1 b 2 c 3 $ pugs -e'my %hash;%hash{"a".."c"}=1..3;say "Hash is {%hash}"' Hash is a 1 b 2 c 3 $ pugs -e'my %hash;%hash{"a".."c"}=1..3;say "Hash is %hash.as(q(%s => +%s), q(, ))";' *** Error: No compatible subroutine found: "&as" at -e line 1, column +35-73 $
    Pugs version is 6.2.2.

    After Compline,
    Zaxo