use strict; use warnings; my @array = qw(valuen valued valuec valueq values); for (@array) { if (/valuen/) { print; } else { print ";"; } }