my @new; my $prev= ''; my $found= 0; while( ) { if( $found ) { push @new, $prev . $_; } $found= /string1/; $prev= $_; }