Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 romping around the Monastery: (15)
As of 2014-07-10 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (216 votes), past polls