#!/usr/bin/perl # http://perlmonks.org/?node_id=1194202 use strict; use warnings; my %totals; local $/ = 'violation'; /^([A-Z])(?:_\d+).* (\d+) violation/sm and $totals{$1} += $2 while <DA +TA>; print "$_ number of violations = $totals{$_};\n" for sort keys %totals +; __DATA__ A_01: xxxxxxx xxxxxxxxxx xxx......... 1 violation A_02: xxxxxxx xxxxxxxxxx xxx......... 4 violations B_02: xxxxxxxx xxxxxxxxxx xxx......... 3 violations
In reply to Re: grep the data out of a text file.
by tybalt89
in thread grep the data out of a text file.
by DespacitoPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |