Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: counting string in a text file

by eff_i_g (Curate)
on Jan 13, 2011 at 05:09 UTC ( [id://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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-25 17:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found