# ... my $resultat = safe_backticks( "/usr/sfw/bin/wget", "-t", "2", "-T", "5", "-S", "-O", "-", $url ); my @lines = split /\n/, $resultat; my $anzahl = grep /$pattern/, @lines; # ... sub safe_backticks { my ($cmd, @args) = @_; open (my $pipe, '-|', $cmd, @args) or die "Could not run $cmd @args: $!\n"; my $output = do {local $/; <$pipe>}; defined ($output) or die "read: $!"; unless( close($pipe) ) { my $error = ($? & 0x7f) ? 'Signal ' . ($? & 0x7f) : 'Exit status ' . ($? >> 8); die "$error: $cmd @args"; } return $output; }