#!/usr/bin/perl -w use 5.020; use strict; use warnings; my $TestFile = "testfile"; open (my $tfh,'<',$TestFile) or die "Test File '$TestFile' kann nicht gelesen werden: '$!' !\n"; my @found_arr = (); # nicht %found_arr - das wäre ein Hash while (my $line = <$tfh>) { chomp $line; # push @found_arr, $line if ($line =~ /\(/ .. $line =~ /\)/); if ( $line =~ /\(/ .. $line =~ /\)/) { push @found_arr, $line; last if ( $line =~ /\)/ ); } } # In Perl kann man eine Schleife über ein Array sehr einfach schreiben: for my $found (@found_arr) { say $found; }