use strict; use warnings; my $string = '(abc),(def),(ghi)'; my $substitution = 's/\),\(/\)\n\(/gi'; $_ = $string; eval "$substitution"; print;