# match a line that only contains one new line if ($line =~ /^\n$/) { #### # match a line that only contains one or more whitespace if ($line =~ /^\s+$/) { #### foreach (@blah) { if ($foo) { # foo stuff } else { # other stuff } } #### # open filehandles ... my ($s, $b) = (0,0); my $arc = 'ARCSERVE.NLM'; my @lines = ; foreach my $line (@lines) { if ($line =~ /^\s+$/ and $s) { $b++; last if $b == 2; } $s = 1 if $line =~ /$arc/; print OUTPUT $line if $s and $line !~ /^\s+$/; }