Perl: removing an array element?
by "Peter Newton" <c-newton(at)ihug.co.nz>
|
Date: |
Tue, 1 Feb 2000 14:12:28 +1300 |
To: |
<hwg-techniques(at)hwg.org> |
|
todo: View
Thread,
Original
|
|
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