in reply to Re: Splice not working or is it me?
in thread Splice not working or is it me?

Use grep(): @array = grep !/$regex/, @array; Otherwise, with your while loop:
$x = 0; while ($x < @array) { # NOT <=, but < if ($array[$x] =~ /$regex/) { splice @array, $x, 1 } else { ++$x } }
That way you only increment if a match wasn't found.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Re: Splice not working or is it me?
by neilwatson (Priest) on Sep 14, 2002 at 16:49 UTC