#!/usr/bin/perl use strict; use warnings; my @array = ('#----------','application = OVO3','user = oraovo3','','application = TST1','user = oratst3','#----------'); my @neu = ('application = OVO4','user = oraovo4','','application = TST2','user = oratst4'); print "alt: @array\n\n"; my $start = ''; for my $zaehl (0 .. @array) { if ($array[$zaehl] eq '#----------') { if ($start eq '') { $start = $zaehl + 1; } else { splice @array,$start,$zaehl - 1,@neu; last; } } } print "neu: @array";