Re: improving my code: array of references On Fri, 2007-04-27 at 14:26 -0400, Matthew J. Avitable wrote:
> Pierre,
> >> Thank you, but I got it to work the way I wanted, thanks to Matthew and
> >> Rob's posts:
> >>
> >> map { modify_variable(${$_}) } = \\($var1, $var2, $var3);
> >>     
> 
> To annotate to what Paul said - the above won't work.  The block syntax 
> of map is "map BLOCK LIST".  Plus, it looks like you are going to 
> dereference $_ before it gets passed into the function.  I'm not 
> particularly sure what the statement above will do. :)   The following 
> should work, if your version of modify_variable treats its first 
> argument as a scalar reference.  See my earlier post for an example of 
> how modify_variable could work.
> 
> map { modify_variable($_) } \\($var1, $var2, $var3);  

Good catch. My code would not have compiled with the '=' sign. I should
pay more attention. Thanks


> 
> > And map in void context is generally frowned upon.
> >   
> 
> There's lots of heated debate about this apparently.  I'm certainly not 
> into starting a flame war, so I'll just point out an interesting 
> conversation which explores this topic, pretty well in depth.
> 
> http://www.perlmonks.org/index.pl?node_id=296742
> 
> 
> -m
> 
> -- 
> + Matt J. Avitable: Senior Systems Analyst, Richweb, Inc.
> + Richweb.com: Providing Internet-Based Business Solutions since 1995
> + (804) 747.8592 x 109
> 
> 


-- 
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/


