Okay, I'm a moron.  I somehow missed that last line.  Disregard...

IMHO you probably wouldn't gain any significant performance here even if
you succeeded in the syntax you are looking for because you still have
to do a check for each iteration of the loop.  

The only thing else I can think of is if you knew the element of the
list you wanted to skip ahead of time and then iterated through the
array slice of the elements you wanted to keep.  That might save a few
cycles if the elements you throw away are towards the beginning of your
array, but for the minimal amount you gain it's probably not worth it.

This might be a good one to run by the guys at the beginners@perl.org
mailing list.  There are some guys over there that are pretty sharp when
it comes to picking the right algorithm for a particular task.


-----Original Message-----
From: Timothy Johnson 
Sent: Tuesday, April 18, 2006 2:28 PM
To: 'Ng, Bill'; perl-win32-users@listserv.ActiveState.com
Subject: RE: Iffor


How about this?

###################

use strict;
use warnings;

my @a = (1,2,3,4,5);
foreach(@a){
   unless($_ == 3){
      #do something...
   }
}

###################




-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Ng, Bill
Sent: Tuesday, April 18, 2006 12:59 PM
To: perl-win32-users@listserv.ActiveState.com
Subject: Iffor

<snip>

So if my array was:
@a=(1,2,3,4,5);
And we assume that I don't want to execute the block if the value of $_
is 3 ...

Then, in my head, I'm looking for the WORKING (key word there) version
of this:
-----------
@a = (1,2,3,4,5);
if ($_ != 3) for (@a)
{
  print "something";
  &doSomething();
  print "somethingelse";
  &yada($yada{$ya})
}
-------------

<snip>


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to