in reply to List context with map
Whitout the parens you map is *greedy* and thus eats argument 4 ie the digit 1. There is a good chance you have no cgi param '1' so this becomes undef.
use CGI; my $q = CGI->new( { one => 1, two => 2, three => 3 } ); test( map{$q->param($_)||"${_}_IS_NULL"}qw(one two three) , 4 ); test( ( map{$q->param($_)||"${_}_IS_NULL"}qw(one two three) ), 4 ); sub test { $"=', ';print "Args( @_ )\n" } __DATA__ Args( 1, 2, 3, 4_IS_NULL ) Args( 1, 2, 3, 4 )
Your obvious expectation is that the qw( ) perfoms a useful binding function to the map when in fact you are getting a flat list: func( map{$q->param($_)} 1, 2, 3, 4 )
cheers
tachyon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: List context with map
by ysth (Canon) on Nov 05, 2004 at 09:11 UTC |