The following small patch to TT2.02 Stash.pm allows array indexes
into hashes and arrays (slices) in the same manner as perl. For
example, HASH.ARRAY is an ARRAY:
[HASH.(ARRAY.0), HASH.(ARRAY.1), ...]
and ARRAY.ARRAY is an ARRAY:
[ARRAY.(ARRAY.0), ARRAY.(ARRAY.1), ...]
Craig
*** Template/Stash.pm Fri Apr 6 04:04:58 2001
--- Template/Stash.pm.new Tue Jun 12 22:26:50 2001
***************
*** 457,462 ****
--- 457,466 ----
elsif ($value = $HASH_OPS->{ $item }) {
@result = &$value($root, @$args); ## @result
}
+ elsif ( ref $item eq "ARRAY" ) {
+ # hash slice
+ return [@$root{@$item}]; ## RETURN
+ }
}
elsif ($rootref eq 'ARRAY') {
***************
*** 472,477 ****
--- 476,485 ----
return $value unless ref $value eq 'CODE'; ## RETURN
@result = &$value(@$args); ## @result
}
+ elsif ( ref $item eq "ARRAY" ) {
+ # array slice
+ return [@$root[@$item]]; ## RETURN
+ }
}
# NOTE: we do the can-can because UNIVSERAL::isa($something, 'UNIVERSAL')