Ah, this is much more useful. This one produces the right output on
what you provided. There is some perl lore in there, but basically
here's the flow:
while there are lines coming from stdin
if a line looks like "The Famous Joke of the day", then
print asciii art
what follows is joke material
if a line is the start of another email then
print a delimeter: %
stop printing
if the joke flag is set print this line
end while
print the last % if necessary
#! /usr/bin/perl
$art=" ���`����,��,����`�������`����,��,����`�������`����,��,����`����\n";
$delim=" The Famous Joke of the Day One Liner!";
$joke=0;
while(<>) {
if(m/$delim/) { print "$art\n"; $joke=1;}
if(m/^From .+\@.+/) { print "%\n" if ($joke); $joke=0; }
print $_ if($joke);
}
print "%\n" if($joke);
On Wed, Jan 22, 2003 at 06:27:38PM -0800, Linux Rocks ! wrote:
> Well.. Its a good start, however it grabed a whole lot more, Heres an example
> of a full message:
> Start sample message::::::::::::::::::::
>
> MeMail.com: Joke of the Day
>
> ????`????,??,????`????,??, OUR SPONSOR ,??,????`????,??,????`????
>
> ** FORECLOSED HOMES: NO MONEY DOWN! **
> Try a FREE search in your area. America's largest
> & oldest bank foreclosure service.
>
> FOR A List In Your Area Click Here
> http://www.adreporting.com/dir.php?a=149783&p=28&w=text
>
> Help keep this publication free - visit our sponsor today!
>
>
> HAVE A GOOD CLEAN JOKE ???
> --------------
>
> We Need a Laugh
> Please send along your funnies to
> [EMAIL PROTECTED]
>
> Irreplaceable
> --------------
>
> My six-year-old grandson called his mother from his friend Charlie's
> house and confessed he had broken a lamp when he threw a football in
> their living room.
>
> "But, Mom," he said, brightening, "you don't have to worry about buying
> another one. Charlie's mother said it was irreplaceable."
>
>
> Every Tues and Friday - a New Funny Foto!!
> FUNNY FOTOS
> Click here to view.
> http://www.memail.com/fotos/index.htm
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`???
>
> Quit Smoking in 21 Days Guaranteed!
> The FinalSmoke System is GUARANTEED to help you
> Quit Smoking in less than 30 days or your money back!
> START YOUR SMOKE-FREE LIFE TODAY... GUARANTEED!!!!!
>
> ACT NOW! CLICK BELOW!
> http://www.adreporting.com/dir.php?p=171&a=149783
>
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`???
>
> Dogs teach us many things .....
>
> When loved ones come home, always run to greet them.
>
> Never pass up the opportunity to go for a joyride.
>
> Allow the experience of fresh air and the wind in your face to be
> pure ecstasy.
>
> When it's in your best interest, practice obedience.
>
> Let others know when they've invaded your territory.
>
> Take naps and stretch before rising.
>
> Run, romp, and play daily.
>
> Thrive on attention and let people touch you.
>
> Avoid biting, when a simple growl will do.
>
> On warm days, stop to lie on your back on the grass.
>
> On hot days, drink lots of water and lay under a shady tree.
>
> When you're happy, dance around and wag your entire body.
>
> No matter how often you're scolded, don't buy into the guilt thing and
> pout ... run right back and make friends.
>
> Delight in the simple joy of a long walk.
>
> Eat with gusto and enthusiasm. Stop when you have had enough.
>
> Be loyal.
>
> Never pretend to be something you're not.
>
> If what you want lies buried, dig until you find it.
>
> When someone is having a bad day, be silent, sit close by and nuzzle
> them gently.
>
>
>
>
> Other cool sites to visit:
> --------------------------
>
> Joker, We Have Found Your Money
> http://www.adreporting.com/dir.php?p=25&a=149783
>
>
> Find FREE Things On The Bargain Finder
> http://www.adreporting.com/bargain-finder.htm
>
>
> Free Antenna Reception Booster with every order!
> http://www.adreporting.com/dir.php?p=26&a=149783
>
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`????
>
> MeMail.com: Delivering The Internet Your Way!
>
> SUBSCRIBE mailto:[EMAIL PROTECTED]
> UNSUBSCRIBE MAILTO: [EMAIL PROTECTED]
>
> Advertising Information: http://www.MeMail.com/advertising.html
>
> This copy was delivered to: [EMAIL PROTECTED]
>
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`????
>
> The Famous Joke of the Day One Liner!
>
> "The good people sleep much better at night than the bad people.
> Of course, the bad people enjoy the waking hours much more."
>
> -- Woody Allen
> END sample message::::::::::::::::
>
> Heres the part yours grabed....
> ????`????,??,????`????,??, OUR SPONSOR ,??,????`????,??,????`????
>
> ** FORECLOSED HOMES: NO MONEY DOWN! **
> Try a FREE search in your area. America's largest
> & oldest bank foreclosure service.
>
> FOR A List In Your Area Click Here
> http://www.adreporting.com/dir.php?a=149783&p=28&w=text
>
> Help keep this publication free - visit our sponsor today!
>
>
> HAVE A GOOD CLEAN JOKE ???
> --------------
>
> We Need a Laugh
> Please send along your funnies to
> [EMAIL PROTECTED]
>
> Irreplaceable
> --------------
>
> My six-year-old grandson called his mother from his friend Charlie's
> house and confessed he had broken a lamp when he threw a football in
> their living room.
>
> "But, Mom," he said, brightening, "you don't have to worry about buying
> another one. Charlie's mother said it was irreplaceable."
>
>
> Every Tues and Friday - a New Funny Foto!!
> FUNNY FOTOS
> Click here to view.
> http://www.memail.com/fotos/index.htm
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`???
>
> Quit Smoking in 21 Days Guaranteed!
> The FinalSmoke System is GUARANTEED to help you
> Quit Smoking in less than 30 days or your money back!
> START YOUR SMOKE-FREE LIFE TODAY... GUARANTEED!!!!!
>
> ACT NOW! CLICK BELOW!
> http://www.adreporting.com/dir.php?p=171&a=149783
>
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`???
>
> Dogs teach us many things .....
>
> When loved ones come home, always run to greet them.
>
> Never pass up the opportunity to go for a joyride.
>
> Allow the experience of fresh air and the wind in your face to be
> pure ecstasy.
>
> When it's in your best interest, practice obedience.
>
> Let others know when they've invaded your territory.
>
> Take naps and stretch before rising.
>
> Run, romp, and play daily.
>
> Thrive on attention and let people touch you.
>
> Avoid biting, when a simple growl will do.
>
> On warm days, stop to lie on your back on the grass.
>
> On hot days, drink lots of water and lay under a shady tree.
>
> When you're happy, dance around and wag your entire body.
>
> No matter how often you're scolded, don't buy into the guilt thing and
> pout ... run right back and make friends.
>
> Delight in the simple joy of a long walk.
>
> Eat with gusto and enthusiasm. Stop when you have had enough.
>
> Be loyal.
>
> Never pretend to be something you're not.
>
> If what you want lies buried, dig until you find it.
>
> When someone is having a bad day, be silent, sit close by and nuzzle
> them gently.
>
>
>
>
> Other cool sites to visit:
> --------------------------
>
> Joker, We Have Found Your Money
> http://www.adreporting.com/dir.php?p=25&a=149783
>
>
> Find FREE Things On The Bargain Finder
> http://www.adreporting.com/bargain-finder.htm
>
>
> Free Antenna Reception Booster with every order!
> http://www.adreporting.com/dir.php?p=26&a=149783
>
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`????
>
> MeMail.com: Delivering The Internet Your Way!
>
> SUBSCRIBE mailto:[EMAIL PROTECTED]
> UNSUBSCRIBE MAILTO: [EMAIL PROTECTED]
>
> Advertising Information: http://www.MeMail.com/advertising.html
>
> This copy was delivered to: [EMAIL PROTECTED]
>
>
> ???`????,??,????`???????`????,??,????`???????`????,??,????`????
>
> The Famous Joke of the Day One Liner!
>
> "The good people sleep much better at night than the bad people.
> Of course, the bad people enjoy the waking hours much more."
>
> -- Woody Allen
>
>
> %
>
> So.. The good news is that it didnt loose any of the message that was
> required, and it did add the % fine (a few extra return characters.. but
> thats no problem...) the first qualifier needs to be a bit more refined
> though,
> so... this is a bit more complicated than a grep! If you can explain what its
> doing, that could be helpfull to me and others that want to write simular
> programs :)
> I can kinda figure out parts of it...
>
> Jamie
> Ill try to make some mods to and see what I can do...
>
> Jamie
>
> On Wednesday 22 January 2003 05:51 pm, Cory Petkovsek wrote:
> : Ok, try this perl script:
> :
> : #! /usr/bin/perl
> : $joke=0;
> : while(<>) {
> : if(m/`....,..,/) { $joke=1;}
> : if(m/^From .+\@.+/) { print "%\n" if ($joke); $joke=0; }
> : print $_ if($joke);
> : }
> : print "%\n" if($joke);
> :
> :
> : save it to a file, turn on executable flag and use like this:
> :
> : cat archive inbox | fortunes.pl > fortunes.txt
> :
> : Cory
> :
> : On Wed, Jan 22, 2003 at 05:19:45PM -0800, Linux Rocks ! wrote:
> : > On Wednesday 22 January 2003 01:24 pm, Cory Petkovsek wrote:
> : > : Where is your email located? In an mbox? If so start with grep. Does
> : > : the one liner have a particular format such as:
> : >
> : > I have a couple files they could be in my inbox ( a text file named
> : > inbox), and my archive file (named archive
> : > I want the text between:
> : > "???`????,??,????`???????`????,??,????`???????`????,??,????`????
> : >
> : > The Famous Joke of the Day One Liner!"
> : >
> : > and from
> : >
> : > "From"
> : > Heres a sample one, Infact, it would be nice to keep thier ascii art! and
> : > text about where its from... like the example below...
> : >
> : > ???`????,??,????`???????`????,??,????`???????`????,??,????`????
> : >
> : > The Famous Joke of the Day One Liner!
> : >
> : > Roses are red, Violets are blue. I'm Schizophrenic and so am I.
> : >
> : > The only consistant way I can tell its the end of the text is the From
> : > line in the next message.
> : >
> : > so.... a cat inbox |grep
> : > "???`????,??,????`???????`????,??,????`???????`????,??,????`????
> : >
> : > The Famous Joke of the Day One Liner!" + any other text, untill you see
> : > "From" >> joker
> : > and it would also have to add a % after each instance.
> : >
> : > There is another problem... what if the one liner is "From joes book of
> : > quotes" or something... it will cut that off!, so a better qualifier
> : > would From *@* (ie anyone@anydomain) so it knows thats a new email.
> : >
> : > basic cat and grep im familiar with... but this is a bit more tricky that
> : > Ive done....
> : >
> : > Jamie
> : >
> : > : q: why did the chicken cross the road? because a penguin was chasing it
> : >
> : > Thats a good quote!
> : >
> : > : You want a text file with no newlines or carriage returns, just %
> : > : separating the jokes, right?
> : > :
> : > : On Wed, Jan 22, 2003 at 12:57:59PM -0800, Linux Rocks ! wrote:
> : > : > So, Id like to extract just the one liner portion of email sent from
> : > : > joker.org (ie, I want all the one-liners from all the memail joke of
> : > : > the day messages I have, and a "%" to separate each oneliner, and Id
> : > : > like them put in a text file, then I can make a fortune database
> : > : > with it, and use it with fortune.)
> : > : >
> : > : > What would be the best way to do this?
> : > : >
> : > : > Jamie
> : > : >
> : > : >
> : > : > --
> : > : > No microsoft products were used to produce this message.
> : > : > EUG-LUG Mailing List:
> : > : > http://mailman.efn.org/cgi-bin/listinfo/eug-lug
> : > : >
> : > : > _______________________________________________
> : > : > Eug-LUG mailing list
> : > : > [EMAIL PROTECTED]
> : > : > http://mailman.efn.org/cgi-bin/listinfo/eug-lug
> : > :
> : > : _______________________________________________
> : > : Eug-LUG mailing list
> : > : [EMAIL PROTECTED]
> : > : http://mailman.efn.org/cgi-bin/listinfo/eug-lug
> : >
> : > --
> : > No microsoft products were used to produce this message.
> : > EUG-LUG Mailing List:
> : > http://mailman.efn.org/cgi-bin/listinfo/eug-lug
> : >
> : > _______________________________________________
> : > Eug-LUG mailing list
> : > [EMAIL PROTECTED]
> : > http://mailman.efn.org/cgi-bin/listinfo/eug-lug
> :
> : _______________________________________________
> : Eug-LUG mailing list
> : [EMAIL PROTECTED]
> : http://mailman.efn.org/cgi-bin/listinfo/eug-lug
>
> --
> No microsoft products were used to produce this message.
> EUG-LUG Mailing List:
> http://mailman.efn.org/cgi-bin/listinfo/eug-lug
>
> _______________________________________________
> Eug-LUG mailing list
> [EMAIL PROTECTED]
> http://mailman.efn.org/cgi-bin/listinfo/eug-lug
_______________________________________________
Eug-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug