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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Here's one way--not sure how it would scale though.

Updated to remove a couple of artifacts.

#! perl -slw use strict; use re 'eval'; my $users = { wilma => { pattern => '(?:[Ff]red|Pebbles)' }, betty => { pattern => '(?:(?:(?:[Bb]am ?){1,2})|[Bb]arney)' }, fred => { pattern => '(?i:wilma|barney)' }, barney => { pattern => '(?i:betty|fred)' }, }; our @users; my $bigRe = '(?{ @users = () })' . join( '', map{ qq[(?=.*($users->{$_}{pattern})(?{ \$^N and push our \@users, '$_' + }))?] } keys %$users ); $bigRe = qr[$bigRe]; #print $bigRe; while( <DATA> ) { chomp; $_ =~ m[$bigRe]g; print "users [@users] selected: '$_'" if @users; } __DATA__ *Fred Flintstone. He is a roly-poly rotund fellow. I always found it amazing, that he wore the same outfit day in and day out. Fred works in a stone quarry. He sits atop a dinosaur and makes the dinosaur move + boulders. His boss is Mr. Slate. Fred is the typical prehistoric man. His enormous appetite is amazing. How he managed to keep as slim as he + is, I will never know. haha. Fred is also a member of a lodge and he loves to bowl. His name is twinkletoes at the bowling alley. *Wilma Flintstone. Wilma is married to Fred. She is a slim, willowy woman who wears a provocative-looking dress all the time. How she ende +d up with fat Fred, I will never know. Wilma keeps a very clean and neat looking stone house. I was always amazed at the size of her house. From the outside, it looks small. Wilma and Fred Flintstone have neighbors, who happen to be their closest friends and partners in crime. *Barney Rubble. He is shorter than Fred. He is Fred's best friend and always ends up involved in Fred's shenanigans. Barney rides to work with Fred. This is not a good arrangement because Barney has had to run after Fred on more than one occasion. Barney is also married to a pretty woman. Her name is Betty. *Betty Rubble. She is taller than Barney and weighs about 50 pounds less than him. She has black hair that is usually styled the same way day after day. Her best friend is Wilma, of course. Their houses are side by side, so Betty is at Wilma's house a lot and vice-versa. Neither Betty nor Wilma work for a living. Wilma and Betty have one child each. They are: *Pebbles. She is the daughter of Wilma and Fred. She is a very cute little red headed baby. Of course, over the years, she did grow up. Pebbles is one of the happiest and smartest babies ever on television. *Bam-Bam. Barney and Betty did not give birth to Bam-Bam. Someone left him in a basket on their doorstep in the middle of the night. It just so happens, the night before, Barney and Betty had wished for a child because they wanted to be parents. Bam-Bam is adopted by Barney and Betty. He is a very strong little baby. Of course, Bam-Bam and Pebbles + end up closest of friends, and both family's are happy. Fred Flintstone also has to endure living with animals also. They have + a dinosaur named Dino and a saber toothed tiger cat. Dino really loves + Fred and loves to greet him when he comes homes. Fred, on the other hand, does not like how Dino greets him. Dino is purple and he also just so happens to be a good baby sitter/watchdog for Pebbles. Barney and Betty have a kangaroo type animal named Hoppy. Hoppy and Dino are best friends. Hoppy also lets Bam-Bam get in his pouch. One of the other somewhat main characters of this cartoon is a genie named Kazoo. He only can be seen by Fred and Barney. He has helped Fred get out of more than one fix. In other episodes, when Fred needed + Kazoo, he would not be anywhere around. Fred drives his car with foot power. I was always amazed at the distances he could drive with his feet. You would think that a stone car would be hard to push, let alone drive with your feet. It is just amazing the technology that was available back in the stone age days.

Output:

P:\test>391416 users [barney wilma] selected: '*Fred Flintstone. He is a roly-poly ro +tund fellow. I always found it ' users [barney wilma] selected: 'amazing, that he wore the same outfit +day in and day out. Fred works ' users [barney wilma] selected: 'boulders. His boss is Mr. Slate. Fred +is the typical prehistoric man. ' users [barney wilma] selected: 'is, I will never know. haha. Fred is a +lso a member of a lodge and he ' users [barney wilma fred] selected: '*Wilma Flintstone. Wilma is marri +ed to Fred. She is a slim, willowy ' users [barney wilma fred] selected: 'up with fat Fred, I will never kn +ow. Wilma keeps a very clean ' users [barney wilma fred] selected: 'Wilma and Fred Flintstone have ne +ighbors, who happen to be their ' users [barney betty wilma fred] selected: '*Barney Rubble. He is short +er than Fred. He is Fred's best friend and ' users [barney betty wilma fred] selected: 'always ends up involved in +Fred's shenanigans. Barney rides to work ' users [barney betty wilma fred] selected: 'with Fred. This is not a go +od arrangement because Barney has had to ' users [barney betty wilma fred] selected: 'run after Fred on more than + one occasion. Barney is also married to a ' users [barney] selected: 'pretty woman. Her name is Betty.' users [barney betty fred] selected: '*Betty Rubble. She is taller than + Barney and weighs about 50 pounds ' users [fred] selected: 'day after day. Her best friend is Wilma, of co +urse. Their houses are ' users [barney fred] selected: 'side by side, so Betty is at Wilma's ho +use a lot and vice-versa. ' users [barney fred] selected: 'Neither Betty nor Wilma work for a livi +ng.' users [barney fred] selected: 'Wilma and Betty have one child each. Th +ey are:' users [barney wilma fred] selected: '*Pebbles. She is the daughter of +Wilma and Fred. She is a very cute ' users [wilma] selected: 'Pebbles is one of the happiest and smartest b +abies ever on television.' users [barney betty fred] selected: '*Bam-Bam. Barney and Betty did no +t give birth to Bam-Bam. Someone left' users [barney betty fred] selected: 'so happens, the night before, Bar +ney and Betty had wished for a child ' users [betty fred] selected: 'because they wanted to be parents. Bam-B +am is adopted by Barney and ' users [barney betty wilma] selected: 'Betty. He is a very strong littl +e baby. Of course, Bam-Bam and Pebbles ' users [barney wilma] selected: 'Fred Flintstone also has to endure liv +ing with animals also. They have ' users [barney wilma] selected: 'Fred and loves to greet him when he co +mes homes. Fred, on the other ' users [wilma] selected: 'just so happens to be a good baby sitter/watc +hdog for Pebbles.' users [barney betty fred] selected: 'Barney and Betty have a kangaroo +type animal named Hoppy. Hoppy and ' users [betty] selected: 'Dino are best friends. Hoppy also lets Bam-Ba +m get in his pouch.' users [barney betty wilma fred] selected: 'named Kazoo. He only can be + seen by Fred and Barney. He has helped ' users [barney wilma] selected: 'Fred get out of more than one fix. In +other episodes, when Fred needed ' users [barney wilma] selected: 'Fred drives his car with foot power. I + was always amazed at the '

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

In reply to Re: Matching against list of patterns by BrowserUk
in thread Matching against list of patterns by Eyck

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (8)
    As of 2014-10-31 14:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (217 votes), past polls