| 1 | ####################################################################### | ||
| 2 | # housekeeping | ||
| 3 | ####################################################################### | ||
| 4 | |||
| 5 | package Object::Exercise v3.1.0; | ||
| 6 | 12 | ▶ | use v5.20; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 12 | ▶ | use Symbol qw( qualify qualify_to_ref ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 12 | ▶ | use Object::Exercise::Execute; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | ######################################################################## | ||
| 13 | # package variables | ||
| 14 | ######################################################################## | ||
| 15 | |||
| 16 | ######################################################################## | ||
| 17 | # subroutines | ||
| 18 | ######################################################################## | ||
| 19 | |||
| 20 | sub import | ||
| 21 | 12 | ▶ | { |
|
Subroutine
import: called CC=1 SCAR=0.0
| |||
| 22 | 12 | state $init = \&Object::Exercise::Execute::import_flags; | |
| 23 | 12 | state $handler = \&Object::Exercise::Execute::exercise; | |
| 24 | |||
| 25 | 12 | my $caller = caller; | |
| 26 | |||
| 27 | # ignore the current package | ||
| 28 | |||
| 29 | 12 | shift; | |
| 30 | |||
| 31 | 12 | my $export = &$init; | |
| 32 | |||
| 33 | # install the handler as scalar ref not a sub ref so that | ||
| 34 | # they get $exercise as a subref. | ||
| 35 | |||
| 36 | 12 | *{ qualify_to_ref $export => $caller } = \$handler; | |
| 37 | |||
| 38 | return | ||
| 39 | 12 | } | |
| 40 | |||
| 41 | # keep require happy | ||
| 42 | 12 | 1 | |
| 43 | __END__ | ||