jeanluca has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
Most of the time map surprises me, it always generates output I don't expect. This time however it goes beyond this. Here is my test code:
This is truly map magic for me! Anyone out there who has already walked this path ?
CHeers LuCa
Update: thnx monks, I appreciate the help!!
Most of the time map surprises me, it always generates output I don't expect. This time however it goes beyond this. Here is my test code:
Which returns#! /usr/bin/perl -l use strict; use warnings ; my @arr = qw(1 2 3 4 5) ; my %h = map { "$_" => "$_" } @arr ; print "$_ --> $h{$_}" foreach ( keys %h ) ;
However when I change the map-line into: my %h = map { $_."" => "$_" } @arr ; it works and producessyntax error at ./t.pl line 7, near "} @arr " Execution of ./t.pl aborted due to compilation errors.
4 --> 4 1 --> 1 3 --> 3 2 --> 2 5 --> 5
This is truly map magic for me! Anyone out there who has already walked this path ?
CHeers LuCa
Update: thnx monks, I appreciate the help!!
Back to
Seekers of Perl Wisdom