in reply to Re: Transforming a for loop to a more functional approach?
in thread Transforming a for loop to a more functional approach?

But ofcourse! The first element is the key and the next is its value! What's wrong with me :-(
Nice answer both of you!

An unrelated question, why not just :
use Data::Dumper;

Replies are listed 'Best First'.
Re^3: Transforming a for loop to a more functional approach?
by GrandFather (Saint) on Mar 03, 2009 at 02:33 UTC

    Habit mostly. I like Streamer's default output better and I don't have to remember to print the result:

    use Data::Dumper; use Data::Dump::Streamer; my @ListOfRecords = qw(1 a 2 b 3 c 4 d); my %MappingOfRecords = reverse @ListOfRecords; print Dumper \%MappingOfRecords; Dump \%MappingOfRecords;

    Prints:

    $VAR1 = { 'c' => '3', 'a' => '1', 'b' => '2', 'd' => '4' }; $HASH1 = { a => 1, b => 2, c => 3, d => 4 };

    True laziness is hard work