in reply to count the occurrence of second line of a paragraph in a file
foreach my $str ($line)
$line is a single thing (scalar), you need to split it into lines manually.
I'd create a hash of hashes keyed by the counted string, each inner hash containing the whole block to print and the count:
while (my $block = <$fh>) { chomp $block; my @lines = split /\n/, $block; unless ($seen{ $lines[1] }{count}++) { $seen{ $lines[1] }{block} = $block; } } for my $str (sort keys %seen) { printf {$fa} "%-s %s", @{ $seen{$str} }{qw{ block count }}; print {$fa} ":".$input_file."\n"; } }
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|