my $class = shift; # at the top of the function return bless \@deck, $class; # at the bottom #### use List::util; # use the module but do not import shuffle # ... sub shuffle { my $deck = shift; my $out = wantarray ? [] : $deck; @$out = List::Util::shuffle(@$deck); return wantarray ? @$out : $out; }