Re: removing element of array

2004-05-16 Thread David Storrs
On Fri, May 14, 2004 at 10:35:45PM -0500, Andrew Gaffney wrote: > Charles K. Clarkson wrote: > >Andrew Gaffney <[EMAIL PROTECTED]> wrote: > >: > >: This doesn't quite work because I'm removing elements > >: from the array I'm looping through. What would be the > >: best way to take care of this? >

RE: removing element of array

2004-05-14 Thread Charles K. Clarkson
Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED] : : On May 14, Charles K. Clarkson said: : : >sub unmerge { : >my( @arr1, @arr2 ); : >/^!/ ? push @arr1, $_ : push @arr2, $_ foreach @{ $_[0] }; : : I like this better: : : push @{ /^!/ ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }, $_ for

RE: removing element of array

2004-05-14 Thread Jeff 'japhy' Pinyan
On May 14, Charles K. Clarkson said: >sub unmerge { >my( @arr1, @arr2 ); >/^!/ ? push @arr1, $_ : push @arr2, $_ foreach @{ $_[0] }; I like this better: push @{ /^!/ ? [EMAIL PROTECTED] : [EMAIL PROTECTED] }, $_ for @{ $_[0] }; >return ( [EMAIL PROTECTED], [EMAIL PROTECTED] );

RE: removing element of array

2004-05-14 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : Charles K. Clarkson wrote: : > : > print Dumper $array1; : > : > @$array1 = grep ! /^!/, @$array1; : > : > print Dumper $array1; : : Well, I'm working with the data in the array at the same : time I'm trying to remove certain elements. I need to :

Re: removing element of array

2004-05-14 Thread Andrew Gaffney
Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I've modified your code to be more like it is in my program: : : #!/usr/bin/perl : : use strict; : use warnings; : use Data::Dumper 'Dumper'; : : my $array1 = ['test1', 'test2', 'test3', 'test4', '!test5', : 'test6', 'tes

RE: removing element of array

2004-05-14 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I've modified your code to be more like it is in my program: : : #!/usr/bin/perl : : use strict; : use warnings; : use Data::Dumper 'Dumper'; : : my $array1 = ['test1', 'test2', 'test3', 'test4', '!test5', : 'test6', 'test7']; : : print Dumper $ar

Re: removing element of array

2004-05-14 Thread Andrew Gaffney
Andrew Gaffney wrote: Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : Charles K. Clarkson wrote: : > : > I don't understand what result you want to assign to : > the original array ref. Give us an example of what you want : > to end up with and we can get you there. : >

Re: removing element of array

2004-05-14 Thread Andrew Gaffney
Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : Charles K. Clarkson wrote: : > : > I don't understand what result you want to assign to : > the original array ref. Give us an example of what you want : > to end up with and we can get you there. : > : > Starting w

RE: removing element of array

2004-05-14 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : Charles K. Clarkson wrote: : > : > I don't understand what result you want to assign to : > the original array ref. Give us an example of what you want : > to end up with and we can get you there. : > : > Starting with this: : > : > : my $ar

Re: removing element of array

2004-05-14 Thread Andrew Gaffney
Charles K. Clarkson wrote: Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I tried to write a small test script to figure this out, : but I can't get anywhere. I used array references in my : test program, because I need to pull out an element from : an array through a ref and assign the result back

RE: removing element of array

2004-05-14 Thread Charles K. Clarkson
Andrew Gaffney <[EMAIL PROTECTED]> wrote: : : I tried to write a small test script to figure this out, : but I can't get anywhere. I used array references in my : test program, because I need to pull out an element from : an array through a ref and assign the result back to the : same array ref.

Re: removing element of array

2004-05-14 Thread Andrew Gaffney
Andrew Gaffney wrote: Wiggins d'Anconia wrote: Andrew Gaffney wrote: I have an array that I need to remove an element from the middle of. Is there a one-liner way to do this? perldoc -f delete perldoc -f splice Helps? A little, but I don't know how to put it all together. I tried to write a smal

Re: removing element of array

2004-05-14 Thread Andrew Gaffney
Wiggins d'Anconia wrote: Andrew Gaffney wrote: I have an array that I need to remove an element from the middle of. Is there a one-liner way to do this? perldoc -f delete perldoc -f splice Helps? A little, but I don't know how to put it all together. -- Andrew Gaffney Network Administrator Skylin

Re: removing element of array

2004-05-14 Thread Wiggins d'Anconia
Andrew Gaffney wrote: I have an array that I need to remove an element from the middle of. Is there a one-liner way to do this? perldoc -f delete perldoc -f splice Helps? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]