#!/usr/bin/perl -w use strict; open(my $SRC, "<", "$srcfile") or die $!; while (my $line = <$SRC>) { my ($text, $status); if ($line =~ /;FOLD\s*;\s*(Coll.+?);%/) { $comment = $1; ($text, $status) = split(/\s+(\w+)$/, $comment); } else { next; } #mach was mit $text und $status } close $SRC;