for my $text ( qw( one two three four five six seven eight nine ten ) ) { my $uniq_text = $text; # Copy ... # Your code, where $uniq_text is a new variable that was never used before, and noone else has access to. } #### sub InitializeList { my @items; # no need to undef it for my $text ( qw( one two three four five six seven eight nine ten ) ) ... return @items; } my @res = InitializeList(); # get the items from that call