Re: improving my code: array of references

2007-04-28 Thread Randal L. Schwartz
> "Pierre" == Pierre Mariani <[EMAIL PROTECTED]> writes: Pierre> I want to run it on several variables. Pierre> I have the following code that: Pierre> - builds an array of references on the variables, Pierre> - calls the function on the content of the reference, Pierre> - set the content of

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
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 wo

Re: improving my code: array of references

2007-04-27 Thread Matthew J. Avitable
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

Re: improving my code: array of references

2007-04-27 Thread Paul Johnson
On Fri, Apr 27, 2007 at 09:54:37AM -0700, Pierre Mariani wrote: > 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); I think you'll find that syntax is incorrect. And map in void context is generall

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
On Fri, 2007-04-27 at 12:45 -0400, Chas Owens wrote: > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > > On Fri, 2007-04-27 at 12:03 -0400, Chas Owens wrote: > > > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > > > snip > > > > > - modify_variable() doesn't appear to modify anythin

Re: improving my code: array of references

2007-04-27 Thread Chas Owens
On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: On Fri, 2007-04-27 at 12:03 -0400, Chas Owens wrote: > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > snip > > > - modify_variable() doesn't appear to modify anything, otherwise why > > > are you assigning its return value to the scal

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
On Fri, 2007-04-27 at 12:03 -0400, Chas Owens wrote: > On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: > snip > > > - modify_variable() doesn't appear to modify anything, otherwise why > > > are you assigning its return value to the scalar passed as a parameter? > > > It seems to be just a fu

Re: improving my code: array of references

2007-04-27 Thread Chas Owens
On 4/27/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: snip > - modify_variable() doesn't appear to modify anything, otherwise why > are you assigning its return value to the scalar passed as a parameter? > It seems to be just a function. Modify_variable modifies its input variable. I think the

Re: improving my code: array of references

2007-04-27 Thread John W. Krahn
Pierre Mariani wrote: > Matthew and Rob, thank you for your replies. > >> - It's unclear whether you have a fixed set of variables to process. >> Is the list always the same? > > Yes, the list is always the same. > >> - Why are you using references? Are you sure you need to? >> >> - modify_vari

Re: improving my code: array of references

2007-04-27 Thread Pierre Mariani
Matthew and Rob, thank you for your replies. > - It's unclear whether you have a fixed set of variables to process. > Is > the list always the same? Yes, the list is always the same. > - Why are you using references? Are you sure you need to? > > - modify_variable() doesn't appear to modify

Re: improving my code: array of references

2007-04-26 Thread Rob Dixon
Pierre Mariani wrote: Hello everyone, I have a 'modify_variable' function that, well, modifies a variable. I want to run it on several variables. I have the following code that: - builds an array of references on the variables, - calls the function on the content of the reference, - set the co

Re: improving my code: array of references

2007-04-26 Thread Matthew J. Avitable
Hi Pierre, my @tmp = ( $var1, $var2, $var3 ); @tmp = map modify_variable, @tmp; which is better Conway (in Perl Best Practices) prefers the block form of map, since in his opinion, it's more readable. So you could rewrite it as: my @tmp = ( $var1, $var2, $var3 ); @tmp = map { modify_variab

Re: improving my code: array of references

2007-04-26 Thread Paul Johnson
On Thu, Apr 26, 2007 at 03:26:02PM -0700, Pierre Mariani wrote: > anyone know how to create an array of references? my @a = \($a, $b, $c); -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ht

Re: improving my code: array of references

2007-04-26 Thread Pierre Mariani
> # $var1, $var2 and $var3 are set previously > > > for ( \$var1, > >\$var2, > >\$var3, > >) > > > > { > >${$_} = modify_variable ( ${$_} ); > > } > > > > Questions: > > - How do I improve my array definition? > > - How to I call the modify_

Re: improving my code: array of references

2007-04-26 Thread Rodrick Brown
Perfect canidate for Map. On 4/26/07, Pierre Mariani <[EMAIL PROTECTED]> wrote: Hello everyone, I have a 'modify_variable' function that, well, modifies a variable. I want to run it on several variables. I have the following code that: - builds an array of references on the variables, - calls