removing element from array during loop

@list=(1,3,7,2,8,9);
$othernumber=8;

foreach $number(@list)
 {
  if($number==$othernumber)
   {
    # remove $number from @list
   };
 };
LVL 1
superquestionsAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
@list = grep { $_!=$othernumber } @list
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.