title: Why am I getting unexpected results from chained calls to map?
body: <p>I'm using Getopt::Lucid to process CLO and I've run into an interesting and unexpected problem.  The following code:</p>
  
  <pre><code>push @clo_spec, map { Switch($_) } qw(-c -m -s -p),
                  map { Switch($_) } qw(--help --man --usage --version),
                  map { Switch($_) } qw(--debug --verbose),
                  map { Param($_)  } keys %$rc_spec_ref
  ;
  
  my $clo_o = Getopt::Lucid-&gt;getopt(\@clo_spec);
  </code></pre>
  
  <p>generates the following error:</p>
  
  <pre><code>'Getopt::Lucid::Spec=HASH(0x9383847)' is not a valid option name/alias
  </code></pre>
  
  <p>Now, Getopt::Lucid is configured by quoting an string expression representing valid options and then passing those strings to one of six subroutines which return blessed hashes.  Each subroutine represents a type of option; switch, counter, parameter, list or key-pair. </p>
  
  <p>The interesting part is that if any three map expressions are removed,</p>
  
  <pre><code>push @clo_spec, #map { Switch($_) } qw(-c -m -s -p),
                  map { Switch($_) } qw(--help --man --usage --version),
                  #map { Switch($_) } qw(--debug --verbose),
                  #map { Param($_)  } keys %$rc_spec_ref
  ;
  </code></pre>
  
  <p>then everything works fine.  The even more interesting part is that if you encase each map expression in parentheses, everything also works fine:</p>
  
  <pre><code>push @clo_spec, (map { Switch($_) } qw(-c -m -s -p)),
                  (map { Switch($_) } qw(--help --man --usage --version)),
                  (map { Switch($_) } qw(--debug --verbose)),
                  (map { Param($_)  } keys %$rc_spec_ref)
  ;
  </code></pre>
  
  <p>The above leads me to believe that this problem isn't related to a bug in Getopt::Lucid.  Also, I considered the above fix after looking at the map function's reference which mentions that sometimes map can get confused with commas.  Perl will flatten embedded lists, and the surrounding parentheses seem to have the effect of delineating each map expression,  but I really don't understand what's going on.</p>
  
  <p>Can someone please explain?</p>