Hi,
Is it possible to loop an array and remove the current item with shift?
e.g.
Which should result in a list of numbers (1,2,3,4,6,7,8,9)
Is it possible and is it advisable altering an array while looping it?
Thanks,1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Dance Music Downloads
Is it possible to loop an array and remove the current item with shift?
e.g.
Code:
my @arr = (1,2,3,4,5,6,7,8,9);
foreach my $item (@arr)
{
shift if $item == 5;
}
print "@arr";
Is it possible and is it advisable altering an array while looping it?
Thanks,1DMF
"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."
"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Dance Music Downloads