| 1 | package overload::x; | ||
| 2 | 1 | ▶ | use 5.006; use strict; use warnings; our $VERSION = '0.02'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use base 'Import::Export'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | use Function::Fallback::CoreOrPP qw(clone); | ||
| 5 | |||
| 6 | our %EX = ( | ||
| 7 | n => [qw/all/], | ||
| 8 | x => [qw/all/] | ||
| 9 | ); | ||
| 10 | |||
| 11 | use overload | ||
| 12 | 'x' => \&x; | ||
| 13 | |||
| 14 | sub n { | ||
| 15 | return bless \shift, __PACKAGE__; | ||
| 16 | } | ||
| 17 | |||
| 18 | sub x { | ||
| 19 | my ($times, $obj) = @_; | ||
| 20 | my $o = ref $times; | ||
| 21 | my @times = map { | ||
| 22 | ref $obj ? clone($obj) : $obj | ||
| 23 | } 1 .. ($o ? $$times : $times); # IN list context this counts which suckkks... | ||
| 24 | wantarray && !$o ? @times : \@times; | ||
| 25 | } | ||
| 26 | |||
| 27 | 1; | ||
| 28 | |||
| 29 | __END__ | ||