in reply to Re^3: converting an array to an hash
in thread converting an array to an hash

I mean an hash of array of numbers, i.e.:

%hash = (1 => 3, 4, 5, 1, 2 => 1, 2, 3, 4, 3 => 3, 3, 1, 6);

Replies are listed 'Best First'.
Re^5: converting an array to an hash
by BrowserUk (Patriarch) on Dec 22, 2014 at 18:49 UTC
    I mean an hash of array of numbers, i.e.:

    See PerlDataStructureCookbook

    my %hash = ( 1 => [ 3, 4, 5, 1 ], 2 => [ 1, 2, 3, 4 ], 3 => [ 3, 3, 1, 6 ], );

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^5: converting an array to an hash
by karlgoethebier (Abbot) on Dec 22, 2014 at 20:26 UTC

    I guess. Do you mean this?

    #!/usr/bin/env perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Sortkeys = 1; my @data = ( [ 3, 4, 5, 1 ], [ 1, 2, 3, 4 ], [ 3, 3, 1, 6 ] ); my %hash = map { $_ => $data[$_] } 0 .. $#data; print Dumper \%hash; __END__ $VAR1 = { '0' => [ 3, 4, 5, 1 ], '1' => [ 1, 2, 3, 4 ], '2' => [ 3, 3, 1, 6 ] };

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»