Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Iterating through an array using multiple loops and removing array elements

by hdb (Prior)
on Apr 24, 2014 at 07:36 UTC ( #1083539=note: print w/ replies, xml ) Need Help??


in reply to Iterating through an array using multiple loops and removing array elements

I am not sure what you want to achieve as @entries will be empty after the while loop whatever you do inside... However, the following should do what you want (not tested as I could not think of sample data).

while( @entries ) { my $top = shift @entries; @entries = map { compare_sub( $top, $_ ) > $user_defined_value ? $ +_ : () } @entries; }

UPDATE: Reading the whole thread more carefully I realize that my proposal is essential the same (but more convoluted) as Tanktalus' grep above. Pls ignore...


Comment on Re: Iterating through an array using multiple loops and removing array elements
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1083539]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2015-07-28 04:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (252 votes), past polls