> In the last episode (Mar 27), Giorgos Keramidas said:
> > On 2003-03-26 14:18, Kenzo <[EMAIL PROTECTED]> wrote:
> > You don't need Perl for that.  Here's a small trick:
> >     grep 'this' file | wc -l
> >     grep 'that' file | wc -l
> Even better:
>       grep -c 'this' file
>       grep -c 'that' file

Unfortunately, that's not what he was asking for, which is to look for 
the pattern "big <foo>" where all the possible <foo>s are unknown and
report on all the <foo>s that were found.

So something like:

        while (<>) {
                while (/big\s+(\w+)/g) {
                        $count{$1}++;
                }
        }

        foreach $word (sort(keys(%count))) {
                print "$word: $count{$word}\n";
        }


ought to do the trick.  Play with $/, etc if you want to allow big and
<foo> to be across a newline from each other.
-- 
Steve Willoughby          | "The purpose of IT is to seamlessly and trans-
Intel DPG Eng. Computing  | parently provide the other nine-tenths of the
Application Development   | iceburg for people who need to work with chunks 
<[EMAIL PROTECTED]>  | of floating ice."           --Strata R. Chalup


_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to