#!/usr/bin/perl use warnings; use strict; use Test::More; sub trim_nonempties { ## no critic (ProhibitMutatingListFunctions) grep { !/^\s*$/ && s/^\s*|\s*$//g } @_; ## use critic } sub choroba { grep !/^$/, map s/^\s+|\s+$//gr, @_ } my @X = ( ' hello ', "\thello again\t", '', " ", " \t", 'jock', "\t abc", "def \t " ); my @changed = @X; my @y = trim_nonempties(@changed); my @stay = @X; my @w = choroba(@stay); is_deeply(\@y, \@w, 'same'); is_deeply(\@X, \@stay, 'no mutation'); done_testing();