Read the last sentence of my email ... =)

Bill Ng 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Jerry Kassebaum
Sent: Tuesday, April 18, 2006 6:07 PM
To: [email protected]
Subject: RE: Iffor

@a = (1,2,3,4,5);

for $x (@a)

{
        if($x==3){next;}
        print "$x\n";

}

##########

You wrote:

Syntax issue (I think),

I'm trying to do the following:
I need to execute a block of instructions for all items in an array
except for one.

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})
}
-------------

But that if ... for line doesn't work.
Neither does:
------------------------
for (@a, $_ != 3) {}
------------------------

Anyone got any ideas?  I've always done this by running a standard for
loop and having an if condition inside the loop .. but that seems
inefficient to me right now and I'm looking for the easier way.

Bill Ng


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to