#!/usr/bin/perl use strict; my @a = qw( a b c d ); my @z; for (@a) { chomp; s/(d)/new(\1)/; push ( @z, $_ ); } print join ",", @z;