Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Extracting ranged data

by BigGuy (Friar)
on Jul 24, 2002 at 20:21 UTC ( [id://185015]=note: print w/replies, xml ) Need Help??


in reply to Extracting ranged data

THis is quick and dirty and just assumes that your data is structured the way you did in your post.
#!/usr/bin/perl open IN, "in.txt" or die "Can't Open input\n"; $count = 0; while (<IN>) { chomp($_); if ($_ =~ /Users/) { print $_,"\t=\t"; } elsif ($_ =~ /\.\.\./) { print $count,"\n"; $count = 0; } else { if ($_) { $count++; } } }
gives this as a result from your example data
Users of some feature = 3 Users of some other feature = 3 Users of yet another feature = 0


BigGuy
"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler

Replies are listed 'Best First'.
Re: Re: Extracting ranged data
by blaze (Friar) on Jul 24, 2002 at 21:21 UTC
    Like BigGuy said, his example is assuming that you have one text file set up exactly like what you have posted which looks like:
    Users of some feature
    
       user1
       user2
       user3
       ...
    
    Users of some other feature
    
       user1
       user2
       user3
       ...
    
    Users of yet another feature
    
    ...
    
    Is that the case?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2024-04-19 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found