sub extract { my $aref=shift; my @out=@{$aref}[@_]; @$aref=@{$aref}[grep !($_ ~~ @_) => 0..$#$aref]; @out; } #### #!/usr/bin/perl use strict; use warnings; use 5.010; use autobox; use Data::Dumper; sub ARRAY::extract { my $aref=shift; my @out=@{$aref}[@_]; @$aref=@{$aref}[grep !($_ ~~ @_) => 0..$#$aref]; @out; } my @x0 = my @x = 'a'..'g'; my @y = @x->extract(2,3,-8); print Dumper \(@x0, @y, @x); __END__ #### # -*- Perl -*- use strict; use warnings; use 5.010; package Array::Extract; use base qw/autobox/; sub import { my $class = shift; $class->SUPER::import(ARRAY => 'Array::Extract::Work'); } package Array::Extract::Work; sub extract { my $aref=shift; my @out=@{$aref}[@_]; @$aref=@{$aref}[grep !($_ ~~ @_) => 0..$#$aref]; @out; } 1; __END__ #### use Array::Extract; my @x = 'a'..'g'; my @y = @x->extract(2,3,-8);