foreach(@array) { (my @test) = $_ =~ /(Dut No.*?)Dut No/gsm; print @test; }