for (@arr1) { #for each element in @arr1 s/\s+$//; #replace one or more spaces at the end of it #with nothing (deleting them) }