Though this seems to be heading the wrong way but - TIMTOWTDI
my @SmtpIndex =
   qw[ DebugTrace smtp port username password from to Subject Text FileName
];

my @SmtpValues = ["1", "smtps://smtp.zoho.com", "465", '[email protected]',
"NaYukYukYuk",
'[email protected]', @['[email protected]','[email protected]'], "Stooges",
"Certainly!", @[""] ];

my %Smtp = zip @SmtpIndex, @SmtpValues;

I guess I could imagine the values coming from a fixed order data file, so
a loop would do the zip with a split of each line but ...


On Tue, Oct 3, 2017 at 1:21 PM, ToddAndMargo <[email protected]> wrote:

> Sweet!    I added a reverse print to the pile!
>
> <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] }" => @[""] ];
>
> sub output(%hash, @index=@SmtpIndex) {
>     for @index -> $key {
>         printf "%10s = %s\n", $key, %hash{$key};
>     }
>     print "\n";
> }
>
> sub revoutput(%hash, @index=@SmtpIndex) {
>     for reverse ( @index ) -> $key {
>         printf "%10s = %s\n", $key, %hash{$key};
>     }
>     print "\n";
> }
>
>
> my @SmtpValues = %Smtp{@SmtpIndex};
>
> my %Smtp2 = do {
>     my $index = 0;
>     @SmtpValues.map: { "{ @SmtpIndex[$index++] }" => $_ };
> };
>
> my %Smtp3 = gather for [email protected] {
>     take @SmtpIndex[$_] => @SmtpValues[$_].Str;
> };
>
> my %Smtp4 = @SmtpIndex Z=> @SmtpValues;
>
> # These are all equivalent
> # output(%Smtp);
> # output(%Smtp2);
> # output(%Smtp3);
> output(%Smtp4);
>
> # print in reverse
> revoutput(%Smtp4);
> </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 =
>
>   FileName =
>       Text = Certainly!
>    Subject = Stooges
>         to = [email protected] [email protected]
>       from = [email protected]
>   password = NaYukYukYuk
>   username = [email protected]
>       port = 465
>       smtp = smtps://smtp.zoho.com
> DebugTrace = 1
>



-- 

a

Andy Bach,
[email protected]
608 658-1890 cell
608 261-5738 wk

Reply via email to