Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: parsing a file to get the count alone

by reneeb (Chaplain)
on Nov 07, 2006 at 09:58 UTC ( #582599=note: print w/replies, xml ) Need Help??


in reply to parsing a file to get the count alone

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

Replies are listed 'Best First'.
Re^2: parsing a file to get the count alone
by Hofmator (Curate) on Nov 07, 2006 at 10:32 UTC
    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
Node Status?
node history
Node Type: note [id://582599]
help
Chatterbox?
[hippo]: Yary: There are a few useful pointers in I need perl coding standards
[hippo]: ... and a boatload of good stuff in On Coding Standards and Code Reviews
[Yary]: Looking at system pm's, looks like it's "package" on the first line, then POD, then "use 5.xyz;use strict; use warnings; use modules..."
[Yary]: ah thanks for those links
[hippo]: Just bear in mind that all such ideas are subjective.
[choroba]: There might be a different standard at the shop you write the code for.
[choroba]: The order of package - (strict+warnings | warnings+strict) - modules makes sense, POD and strict-warnings order are not so important

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2018-01-23 17:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (250 votes). Check out past polls.

    Notices?