Re: wipe out elements in an array

2002-04-29 Thread drieux
On Monday, April 29, 2002, at 01:52 , Bryan R Harris wrote: > Out of curiosity, do the $, $/ $\ variables maintain their values between > runs? Or are they reset before running a new script? the short answer is that 'All Perl Special Variables are set to the default upon invocation' - hence if

Re: wipe out elements in an array

2002-04-29 Thread Bryan R Harris
Thanks to all for the tips, and for introducing me to the grep and splice functions. As a sidenote, I mucked around and discovered that for my purposes, just assigning that element to "" works fine, since I'm just printing the results back out to a file and the individual elements have their new

Re: wipe out elements in an array

2002-04-25 Thread drieux
On Thursday, April 25, 2002, at 05:37 , Peter Scott wrote: > > Use splice() if you want to remove a known number of elements that are > all adjacent and start from a known offset. Otherwise, use grep: > > @myarray = grep { $_ != 3 && $_ != 5 } @myarray > > If you want to remove element

Re: wipe out elements in an array

2002-04-25 Thread drieux
On Thursday, April 25, 2002, at 04:58 , Bryan R Harris wrote: > My guess (this is just an example): > > @myarray = (1,2,3,4,5,6,7,8,9,10); > foreach (@myarray) { if ($_ == 3 || $_ == 5) { undef($_); } } what you want to look at is perldoc -f splice one way to hack a solution here woul

Re: wipe out elements in an array

2002-04-25 Thread Peter Scott
At 08:24 PM 4/25/02 -0400, Jeff 'japhy' Pinyan wrote: >On Apr 25, Bryan R Harris said: > > >I'd like to remove all elements in an array that meet a certain criteria > >without changing their order. I'm sure this gets done all the time, but > >I'm not sure how to do it... > >You want splice() inst

Re: wipe out elements in an array

2002-04-25 Thread bob ackerman
On Thursday, April 25, 2002, at 05:24 PM, Jeff 'japhy' Pinyan wrote: > On Apr 25, Bryan R Harris said: > >> I'd like to remove all elements in an array that meet a certain criteria >> without changing their order. I'm sure this gets done all the time, but >> I'm not sure how to do it... > > You

Re: wipe out elements in an array

2002-04-25 Thread Jeff 'japhy' Pinyan
On Apr 25, Bryan R Harris said: >I'd like to remove all elements in an array that meet a certain criteria >without changing their order. I'm sure this gets done all the time, but >I'm not sure how to do it... You want splice() instead. perldoc -f splice -- Jeff "japhy" Pinyan [EMAIL P

wipe out elements in an array

2002-04-25 Thread Bryan R Harris
I have another question that Learning Perl doesn't seem to address: I'd like to remove all elements in an array that meet a certain criteria without changing their order. I'm sure this gets done all the time, but I'm not sure how to do it... Help? My guess (this is just an example): @myarray