On Wed, 28 May 2008 09:22:23 -0700, David Wheeler (via RT) <perlbug-followup@perl.org> wrote: > When I run this code: > > my @a = map { "--$_" => $_ } @ARGV; > > I get this compile-time error: > > Not enough arguments for map at /Users/david/bin/try line 6, near "} @ARGV" > syntax error at /Users/david/bin/try line 6, near "} @ARGV" > Execution of /Users/david/bin/try aborted due to compilation errors. Enough explanation has already been passed back $ perl -wle'my@a=map{"--$_"=>$_}@ARGV;print"(@a)"' foo bar Not enough arguments for map at -e line 1, near "}@ARGV" syntax error at -e line 1, near "}@ARGV" Execution of -e aborted due to compilation errors. using a semi-colon $ perl -wle'my@a=map{;"--$_"=>$_}@ARGV;print"(@a)"' foo bar (--foo foo --bar bar) using parens $ perl -wle'my@a=map{("--$_"=>$_)}@ARGV;print"(@a)"' foo bar (--foo foo --bar bar) using a unary + $ perl -wle'my@a=map{+"--$_"=>$_}@ARGV;print"(@a)"' foo bar (--foo foo --bar bar) using catenation $ perl -wle'my@a=map{"--".$_=>$_}@ARGV;print"(@a)"' foo bar (--foo foo --bar bar) I personally think that using parens here to disambuigate is the most verbose option without adding unexplainable line noise -- H.Merijn Brand Amsterdam Perl Mongers (http://amsterdam.pm.org/) using & porting perl 5.6.2, 5.8.x, 5.10.x on HP-UX 10.20, 11.00, 11.11, & 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin. http://qa.perl.org http://mirrors.develooper.com/hpux/ http://www.test-smoke.org http://www.goldmark.org/jeff/stupid-disclaimers/Thread Previous | Thread Next