#!/usr/bin/perl use strict; use warnings; my $file='data.txt'; open(my $fh, '<', $file) or die("ERROR open $file ($!)\n"); { local $/="[Abschnitt]\n"; while(my $block=<$fh>) { chomp($block); next unless($block); my ($id,$data)=split("\n",$block,2); # ... print "BLOCK: $id\n"; print "DATA:\n$data\n"; print "#####################\n"; # ... } } close($fh);