in reply to Re^2: Splicing Arrays on pre-defined indices
in thread Splicing Arrays on pre-defined indices
# Assume below line is read from a file my @array = qw/i will skip some words here using splice/; print "Array before deletion \n"; print join("-->",@array),"\n"; print "Enter the Indices which you like to skip\n"; chomp($indices=<STDIN>); # i entered 2,4,5 my @indices = split(/\,/,$indices); foreach (@indices){ splice (@array,$_,1); # remove element } print "Updated array is as below \n"; print join("==>",@array),"\n"; # if there is any easy way of doing above in short , i can integrate i +n my existing code
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Splicing Arrays on pre-defined indices
by BrowserUk (Patriarch) on Jun 27, 2008 at 18:15 UTC |