Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

parsing a file to get the count alone

by Anonymous Monk
on Nov 07, 2006 at 04:29 UTC ( #582560=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: parsing a file to get the count alone
by dewey (Pilgrim) on Nov 07, 2006 at 05:34 UTC
    I don't really understand what you are asking for here. In order to make the most of the site, please take a look at How (Not) To Ask A Question. Thanks!
    Now, given your post, I am guessing you may find (Count the number of lines in a file) useful. It is a little bit obfuscated, but it can be run straight from the command line. If this doesn't help, could you clarify what you mean by "elements"?
    ~dewey
Re: parsing a file to get the count alone
by reneeb (Chaplain) on Nov 07, 2006 at 09:58 UTC
    Maybe you need something like this:

    #!/usr/bin/perl use strict; use warnings; local $/ = "\nGenerating"; while(my $entry = <DATA>){ my ($table,$count) = $entry =~ /Summary of ([^\s]+).*(\d+)/s; print $table,": ",$count,"\n" if $count > 1; } __DATA__ Generating Summary of table_1 (count(*)) 1 Generating Summary of table_2 (count(*)) 2
      I guess that is (close to) what Anonymous Monk wanted.

      Just a small remark, [^\s]+ can be written /S+ in your regex.

      -- Hofmator

      Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2022-06-29 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (96 votes). Check out past polls.

    Notices?