Andrew Gaffney <[EMAIL PROTECTED]> wrote:
: 
: I've modified your code to be more like it is in my program:
: 
: #!/usr/bin/perl
: 
: use strict;
: use warnings;
: use Data::Dumper 'Dumper';
: 
: my $array1 = ['test1', 'test2', 'test3', 'test4', '!test5', 
: 'test6', 'test7'];
: 
: print Dumper $array1;
: 
: for my $lv (0..$#{$array1}) {
:    splice @$array1, $lv, 1 if($array1->[$lv] =~ /^!/);
: }
: 
: print Dumper $array1;
: 
: This doesn't quite work because I'm removing elements
: from the array I'm looping through. What would be the
: best way to take care of this?


    Don't use splice:    :)

print Dumper $array1;

@$array1 = grep ! /^!/, @$array1;

print Dumper $array1;


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328


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