in reply to Counting between the lines
Output:#!/usr/bin/perl use warnings; use strict; my %hash; my $name; while (<DATA>){ if (/word\s(\d+)/){ $name = $1; } elsif (! /#/){ $hash{$name}++; } } for my $key (keys %hash){ print "$key $hash{$key}\n"; } __DATA__ # run1 # word 26871 # text returns text text text # run2 # word 26872 # text returns text text #run3
26871 3 26872 2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting between the lines
by gaal (Parson) on Dec 14, 2004 at 07:35 UTC |