Re: removing an array element?

by "Darrell King" <darrell(at)webctr.com>

 Date:  Tue, 1 Feb 2000 05:26:38 -0500
 To:  "hwg-techniques" <hwg-techniques(at)hwg.org>
 References:  co
  todo: View Thread, Original
splice(@array,element,length)...?

Darrell

----- Original Message -----
From: "Peter Newton" <c-newton(at)ihug.co.nz>
To: <hwg-techniques(at)hwg.org>
Sent: Monday, January 31, 2000 8:12 PM
Subject: Perl: removing an array element?


> Hello All,
>
> Is their a SIMPLER way than this to remove a parlicular element from
an
> array:-
>
> @array= split(/ /,"entry1 entry2 entry3 entry4 entry5 entry6");
>
> print "array = @array\n";
>
> $count=0;
> $elementno=3;
>
> foreach $line(@array){
>  if ($count != $elementno) {push (@newarray,$line);}
>  ++$count;
> }
>
> $array=$newarray;
> print "array = @array\n";
>
> This seems very cumbersome it would be nice if their was something
like:-
>
> delete(@array[3]);   or
> remove(@array,3);
> or something like that
>
> Many thanks
> Peter Newton
>
>
>
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA