| 1 | package Text::Xslate::HashWithDefault; | ||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 6 | ▶ | use Tie::Hash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 6 | our @ISA = qw(Tie::ExtraHash); | |||||||||
| 6 | |||||||||||
| 7 | 10 | ▶ | sub TIEHASH { | ||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 10 | my($class, $storage, $default) = @_; | |||||||||
| 9 | 10 | return bless [ $storage, $default ], $class; | |||||||||
| 10 | } | ||||||||||
| 11 | |||||||||||
| 12 | 23 | ▶ | sub FETCH { | ||||||||
|
Subroutine
FETCH: called CC=3 SCAR=11.0
| |||||||||||
| 13 | 23 | my($self, $key) = @_; | |||||||||
| 14 | 23 | ▶ | if(exists $self->[0]{$key}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | 5 | return $self->[0]{$key}; | |||||||||
| 16 | } | ||||||||||
| 17 | else { | ||||||||||
| 18 | 18 | ▶ | return ref($self->[1]) eq 'CODE' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | ? $self->[1]->($key) | ||||||||||
| 20 | : $self->[1]; | ||||||||||
| 21 | } | ||||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 6 | 1; | |||||||||
| 25 | __END__ | ||||||||||