Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-28 08:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls