in reply to simple array question
You remove elements from arrays with splice. A short excerpt from perldoc -f splice:
- splice ARRAY,OFFSET,LENGTH,LIST
- Removes the elements designated by OFFSET and LENGTH from an array, and replaces them with the elements of LIST, if any.
push, pop, shift, and unshift can all be expressed as a splice. In your case, you want to delete one entry so specify its index as OFFSET and 1 for LENGTH. You aren't replacing this range with anything so leave off LIST. So splice @1,$i,1 (are you really using numbers for your array names? that sounds kind of odd).
Also, since in your example you want to remove the last entry from the list, you could use pop.
--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
|
|---|