use strict; use warnings; my @array = "abc\ndef\nghi\n"; print $1 . $3 if $array[0] =~ /(.*)(\ndef)(.*)/s;