Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/local/bin/perl # # (c) Bart Lateur 20/21 sept 2003 # This is free software. Just don't pretend YOU wrote it! # framework based on example 8.1 of Lincoln Stein's book, # "Network Programming with Perl" # Edit these to your personal settings: my($host, $login, $passwd) = qw( mylogin mypasswo +rd); use strict; use Net::POP3; use Mail::Header; my $pop = Net::POP3->new($host, Timeout=>30) or die "Can't connect to +$host: $!\n"; my $messages = $pop->login($login => $passwd) or die "Can't log in: " +, $pop->message,"\n"; printf "Check at %s\n", scalar localtime; my $delcount = 0; if($messages += 0) { printf "Inbox holds %d message%s\n", $messages, $messages!=1 && 's +'; for my $msgnum (1 .. $messages) { my $header = $pop->top($msgnum, my $linecount = 40); my $parsedhead = Mail::Header->new($header); chomp(my $subject = $parsedhead->get('Subject')); chomp(my $from = $parsedhead->get('From')); my $deleted = 0; my $offset = ''; if($parsedhead->get('Mime-Version')) { my $redone; { local $_ = join "", @$header; tr/\r//d; s/^(.+\n)+\n+//; (undef, $deleted) = m[^--.*\n (?:(?:Content|[\t\ ]).+\n)* Content-(?:Type:\s+\w*/[\w\-]+;\s+ |Disposition:\s+\w+;\s+file) name=("?).*\.(exe|scr|pif|com|dll|bat|cpl)\1$]xmi and $offset = substr($_, 0, $+[0]) =~ tr/\n//; # for earlier perls you can get along (with slightly d +ifferent results) by using: # $offset = $` =~ tr/\n//; last if $deleted || $redone++ || tr/\n// < $linecount; $header = $pop->top($msgnum, $linecount = 700); redo; } } if($deleted) { $pop->delete($msgnum); $delcount++; } printf "%3d %-3s %3s %-25s %s\n", $msgnum, $deleted || 'ok', +$offset, $from, $subject; } printf "%d message%s deleted.\n\n", $delcount, $delcount!=1 && 's' +; } else { printf "%s\n\n", "You don't have pending mail."; } $pop->quit;

In reply to Kill that Swen worm on your POP3 account! by bart

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-08-08 08:22 GMT
Find Nodes?
    Voting Booth?

    No recent polls found