Hello ...

I am trying to figure out, which operator to use; pop, shift or splice.
My goal is,  as an option is selected from user input,  pop or splice or
shift elements off ( those selected from user input ) and repopulate array
with remaining elements.

Scenarios:

as numbers are selected
remove elements from array A
repopulate list with what is remaining into array A
print array A

as numbers are selected
remove elements from array A
repopulate remaining numbers in to array B
print array B

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

@ArrayA=(0 .. 1000);
print @array;  ## User now sees selection list.  This could be replaced
with splice or shift or pop
foreach (splice @ArrayA, @numbers to remove, scalar of @numbers to remove,
@ArrayA)
{
      print $_;
}

# Array A now has 05-1000

OR

@ArrayA=(0 .. 1000);
print @array;  ## User now sees selection list.  This could be replace with
a loop that is popping, shifting or splicing
foreach (@ArrayA)
{
      shift @number to remove;
}
print @ArrayA

# Array A now has 05-1000

OR

@ArrayA=(0 .. 1000);
print @array;  ## User now sees selection list.  This could be replaced
with splice or shift or pop
foreach (splice @ArrayA, @numbers to remove, scalar of @numbers to remove,
@ArrayB)
{
      print $_;
}

#ArrayB now has 05 - 1000


thank you,

derek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to