Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!/usr/bin/perl -- -*-fundamental-*- ## Resume logger ## Greg Sabino Mullane, greg@turnstep.com, 0x14964AC8 ## Note: your log format and mail program may vary: ## Try local 'sendmail' or use Mail::Mailer use strict; my($mail, $mailto, $mailfrom, $subject); my($accesslog, $resumelog, $mydomain, $mypage); my(@fresh, %seenit, %seenIP, %visits); my($x); $mail = "/usr/bin/mail"; ## Paranoia is a Good Thing $mailto = "resume\@example.com"; $mailfrom = qq["Abe Lincoln" <alincoln\@example.com>]; $subject = "More resume nibbles"; $accesslog = "/foo/bar/logs/access_log"; $resumelog = "/home/alincoln/jobs/resume.log"; $mydomain = "turnstep"; ## Use if server has >1 domain... $mypage = "/resume.html"; ## Load our old data: open(OLD, "+< $resumelog") || die "Could not open $resumelog: $!\n"; while(<OLD>) { $seenit{$_}++; ($x) = split(/ /,$_); $seenIP{$x}++; } ## Anything new in the logs? open(ACCESSLOG, "$accesslog") || die "Could not open $accesslog: $!\n" +; while(<ACCESSLOG>) { ## Crude match: refine if other pages contain $mypage next unless m/^$mydomain (.*?) (.*$mypage.*\n)/; $seenit{"$1 $2"} || push(@fresh, "$1 $2") && $visits{$1}++; } close(ACCESSLOG); ## Bail if nothing new: @fresh || exit; ## perl closes OLD for us. Isn't that nice? ## Add new entries to the end of OLD: print OLD @fresh; close(OLD); ## Mail it to us: open(MAILME, "| $mail -t $mailto") || die " Could not start $mail: $!\ +n"; print MAILME "From: $mailfrom\n"; print MAILME "Subject: $subject.\n\n"; for (@fresh) { ($x) = split(/ /, $_); $seenIP{$x} ||=0; print MAILME "\tThis time: $visits{$x} Prior: $seenIP{$x}\n$_\n\n"; } close(MAILME); exit;

In reply to Resume logger by turnstep

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 rifling through the Monastery: (4)
    As of 2014-09-23 04:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (210 votes), past polls