Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Help me not use codefor($i=0;$i=$#array;$i++)/code...Please!

by IraTarball (Monk)
on Jun 21, 2001 at 02:13 UTC ( [id://90225]=note: print w/replies, xml ) Need Help??


in reply to Re: Help me not use codefor($i=0;$i=$#array;$i++)/code...Please!
in thread Help me not use for($i=0;$i=$#array;$i++)...Please!

This was an extremely simplified example to try and get to the core problem. In reality this is an array of arrays inside a hash. I'm looping through doing some processing and certain things should only be processed once but others should be processed multiple times. My solution was to remove them from the array after processing if they were to only be processed once.
After looking at all the great responses here I think @array = grep $_ != 5, @array; is what I want. The 5 would actually be an array reference, but I think this will work.

Thanks for all the help,
Ira.

"So... What do all these little arrows mean?"
~unknown

  • Comment on Re: Re: Help me not use codefor($i=0;$i=$#array;$i++)/code...Please!
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Help me not use codefor($i=0;$i=$#array;$i++)/code...Please!
by Zaxo (Archbishop) on Jun 21, 2001 at 02:30 UTC

    If you bracket it, the grep expression becomes a block. It can be as complicated as you please. If it evaluates true, $_ (possibly modified within the block) is placed in the returned array.

    After Compline,
    Zaxo

    Update: Corrected block <-> expr terminology.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 04:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found