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

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,

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 PROTEC

Re: improving my code: array of references

2007-04-26 Thread Pierre Mariani
k I can use references anymore using this method, but anyone know how to create an array of references? Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

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

improving my code: array of references

2007-04-26 Thread Pierre Mariani
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 content of the

Re: Create array of references

2006-06-12 Thread beginner
On 9 Jun 2006 at 11:55, Peter Cornelius wrote: > The problem you're having is that you're creating a new hash > reference in each of your if/elsif statements. I'm going to make > some assumptions about your data since I don't know anything about > it, but it looks like you want to group back/

Re: Create array of references

2006-06-09 Thread John W. Krahn
beginner wrote: > Hi, Hello, > I am trying to create an array of references but am getting stuck at > how/when to push the reference into the array > > Below is some sample data and a snip of what I have been trying. What > is happening is that the reference $times is getti

Re: Create array of references

2006-06-09 Thread Peter Cornelius
The problem you're having is that you're creating a new hash reference in each of your if/elsif statements. I'm going to make some assumptions about your data since I don't know anything about it, but it looks like you want to group back/home/out times by day. If that's what you want then

Re: Create array of references

2006-06-09 Thread Muma W.
beginner wrote: Hi, I am trying to create an array of references but am getting stuck at how/when to push the reference into the array [...] } elsif ($key =~ /j/ ) { $times = { out => $time}; Try this: $times->{out} = $time; [...] -- To unsubscr

Create array of references

2006-06-09 Thread beginner
Hi, I am trying to create an array of references but am getting stuck at how/when to push the reference into the array Below is some sample data and a snip of what I have been trying. What is happening is that the reference $times is getting pushed into the array before all the keys are

RE: array of references

2004-10-26 Thread Bob Showalter
Scott Pham wrote: > I've been thinking about this and not sure how to approach this > problem. Say I want to create an array of 4 array references, thats > easy since I know that there will be 4 array references, how would I > do this dynamically? Say if one I only needed 2 references and > another

Re: array of references

2004-10-25 Thread Zeus Odin
push @array, [] while @array < 10; also works. "Ed Christian" <[EMAIL PROTECTED]> wrote... push (@array,[]) for (1..$num_child_arrays); For more info: perldoc -f push -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: array of references

2004-10-25 Thread Ed Christian
Scott Pham wrote: > I've been thinking about this and not sure how to approach this > problem. Say I want to create an array of 4 array references, thats > easy since I know that there will be 4 array references, how would I > do this dynamically? Say if one I only needed 2 references and > another

array of references

2004-10-25 Thread Scott Pham
I've been thinking about this and not sure how to approach this problem. Say I want to create an array of 4 array references, thats easy since I know that there will be 4 array references, how would I do this dynamically? Say if one I only needed 2 references and another I need 10 array references,