Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: counting string in a text file

by eff_i_g (Curate)
on Jan 13, 2011 at 05:09 UTC ( #882031=note: print w/ replies, xml ) Need Help??


in reply to counting string in a text file

use warnings; use strict; use Set::IntSpan; my %color; while (<DATA>) { push @{$color{$1}}, $. if /\sbgcolor="([^"]+)"/; } for (sort keys %color) { my $span = Set::IntSpan->new(@{$color{$_}}); print "$_: ", $span->run_list, "\n"; } __DATA__ <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="green" height="10"></td> <td bgcolor="green" height="10"></td> <td bgcolor="green" height="10"></td> <td bgcolor="green" height="10"></td> <td bgcolor="green" height="10"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="green" height="10"></td> <td bgcolor="green" height="10"></td> <td bgcolor="white"></td> <td bgcolor="white"></td> <td bgcolor="white"></td>
green: 6-10,15-16 white: 1-5,11-14,17-19


Comment on Re: counting string in a text file
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://882031]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-08-31 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls