Hi All,

I created a keeper not on hash indexing.  I though
maybe you guys would find it interesting, if for nothing
else, for the syntax used

-T


Perl6: Indexing a hash:

<code>
#!/usr/bin/env perl6

#`{
  Hashes do not print in the order they are created.  it is a Perl 6 thing.
  To overcome this, create an index of the hash.
}

my @SmtpIndex =
qw[ DebugTrace smtp port username password from to Subject Text FileName ];

my %Smtp =
  [ "{ @SmtpIndex[0] }" => "1",
    "{ @SmtpIndex[1] }" => "smtps://smtp.zoho.com",
    "{ @SmtpIndex[2] }" => "465",
    "{ @SmtpIndex[3] }" => '[email protected]',
    "{ @SmtpIndex[4] }" => "NaYukYukYuk",
    "{ @SmtpIndex[5] }" => '[email protected]',
    "{ @SmtpIndex[6] }" => @['[email protected]','[email protected]'],
    "{ @SmtpIndex[7] }" => "Stooges",
    "{ @SmtpIndex[8] }" => "Certainly!",
    "{ @SmtpIndex[9] }" => @[""] ];

for @SmtpIndex -> $key { printf "%10s = %s\n", "$key", "%Smtp{$key}"; }
</code>


$ HashIndexTest.pl6
DebugTrace = 1
      smtp = smtps://smtp.zoho.com
      port = 465
  username = [email protected]
  password = NaYukYukYuk
      from = [email protected]
        to = [email protected] [email protected]
   Subject = Stooges
      Text = Certainly!
  FileName =

Reply via email to