$file =~ s{^\s+description\s\K(\w{4})(-\w+-\w+)(?:=;)}{ my $prefix = $1; my $suffix = $2; # Optional Transformation logic here, giving $prefix and $suffix new values. $prefix.$suffix }mge;