For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > January 2006 > Creating perl script for email "cleaning"









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Creating perl script for email "cleaning"
h7qvnk7q001@sneakemail.com

2006-01-24, 6:56 pm

I am new to Perl, and I would like to create a script to clean "junk"
out of email messages from lists and digests.

The operation I want to achieve is this:

Copy text from input to output,
if <XXX> is seen, discard input text, starting from <XXX>
until <YYY> is seen. After <YYY>, resume copying text from input to
output.
Repeat until EOF(input).

<XXX> is a set of one or more regular expressions. <YYY> is a different
set of regular expressions. Matching within the set is OR (matching
any expression is a trigger)


How would I structure a Perl program to do this? I looked at CPAN but
didn't see anything similar. Can anyone provide a pointer or an example
to something that would work like this?

Thanks!

Paul Lalli

2006-01-24, 6:56 pm

h7qvnk7q...@sneakemail.com wrote:
> I am new to Perl, and I would like to create a script to clean "junk"
> out of email messages from lists and digests.
>
> The operation I want to achieve is this:
>
> Copy text from input to output,
> if <XXX> is seen, discard input text, starting from <XXX>
> until <YYY> is seen. After <YYY>, resume copying text from input to
> output.
> Repeat until EOF(input).
>
> <XXX> is a set of one or more regular expressions. <YYY> is a different
> set of regular expressions. Matching within the set is OR (matching
> any expression is a trigger)
>
> How would I structure a Perl program to do this? I looked at CPAN but
> didn't see anything similar.


What were you expecting to find at CPAN? Your problem description is a
basic usage of file reading and pattern matching.

What have you tried so far? How did it fail to meet your expectations?

> Can anyone provide a pointer or an example
> to something that would work like this?


Are you looking for a pre-built script that meets your job description?
If so, I would suggest you'll have better luck posting at
http://jobs.perl.org, along with a salary offer.

If you're looking for help writing such a script, I suggest you read:
perldoc -f open
perldoc -f print
perldoc -f readline
perldoc perlretut
perldoc perlop (search for 'flip-flop' (no, I'm not kidding))

Once you've made an attempt at solving your problem, if it doesn't
work, you should feel free to post what you have and explain what it
doesn't do that you want it to do.

Paul Lalli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com