in reply to What is a "slice" ?
Slices can also be used with hashes in similar fashion. Oh, and they can be used with literal lists as well.my @array = (1, 2, 3, 4, 5); my @array_slice = @array[0,1,2]; print @array,"\n"; print @array_slice,"\n";
A slice is a new subset list, based on the contents of elements of another list.
UPDATE The arrays in the preceeding examples are simply containers for the data. And the containers are given names that reasonably illustrate what is going on. @array_slice contains a slice that came out of @array. @array_slice is, itself, an array as well.
@array[1,2,3,4] # a slice from an array. @array[1..4] # a slice of sequential elements # from an array. (1,2,3,4)[0,1,2] # a slice of a list. @hash{'Monday', 'Tuesday'} # a slice from a hash.
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: What is a "slice" ?
by Juerd (Abbot) on Aug 23, 2003 at 16:24 UTC |