Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

parsing a file to get the count alone

by Anonymous Monk
on Nov 07, 2006 at 04:29 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found