#!/usr/bin/perl use strict; use warnings; my $output_file = '/dev/null'; my $search = 'test 1'; my $end_of_block = '[end.message]'; open my $outfh, '>>', $output_file or die "$output_file: open failed: $!\n"; while ( my $line = ) { if ( index( $line, $search, 0 ) >= 0 .. index( $line, $end_of_block, 0 ) >= 0 ) { print $outfh $line or die "$output_file: print failed: $!\n"; } } close $output_file or die "$output_file: close failed: $!\n"; __DATA__ test 1 von Computer 4711 MHz = 500 RAM = 256 Screen = 17 Zoll [end.message] test 2 von Computer 0815 MHz = 1500 RAM = 512 Screen = 21 Zoll [end.message]