|
|
|
|
|
by draegtun
4594 days ago
|
|
Plonk that into an autobox module (like perl5i and/or autobox::Core) and enjoying even more caddadadaddaaaaaring around! For eg: use perl5i::2;
sub autobox::Core::ARRAY::car { $_[0]->[0] }
sub autobox::Core::ARRAY::cdr {
my $last = $#{$_[0]};
wantarray ? @{$_[0]}[1 .. $last] : [@{$_[0]}[1 .. $last]];
}
then... my @a = 1..4;
@a->car; # 1
@a->cdr->cdr->car; # 3
@a->cdr; # 2, 3, 4
my @x = @a->cdr;
@x->cdr; # 3, 4
Some refs: https://metacpan.org/pod/perl5i | https://metacpan.org/pod/autobox::Core |
|