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] }" => 'la...@zoho.com',
    "{ @SmtpIndex[4] }" => "NaYukYukYuk",
    "{ @SmtpIndex[5] }" => 'la...@zoho.com',
    "{ @SmtpIndex[6] }" => @['cu...@zoho.com','m...@zoho.com'],
    "{ @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 = la...@zoho.com
  password = NaYukYukYuk
      from = la...@zoho.com
        to = cu...@zoho.com m...@zoho.com
   Subject = Stooges
      Text = Certainly!
  FileName =

Reply via email to