Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Resume logger

by turnstep (Parson)
on Apr 07, 2000 at 21:04 UTC ( #7138=sourcecode: print w/replies, xml ) Need Help??
Author/Contact Info turnstep
Description: Small script to check if anyone has looked at my online resume, and if so, mails the information to me. Run as a periodic cronjob; exits silently if no new matches are found.
#!/usr/bin/perl -- -*-fundamental-*-

## Resume logger
## Greg Sabino Mullane,, 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);

$mail      = "/usr/bin/mail"; ## Paranoia is a Good Thing
$mailto    = "resume\";
$mailfrom  = qq["Abe Lincoln" <alincoln\>];
$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}++;

## 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: $!\
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";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://7138]
[Discipulus]: congrats choroba!
Discipulus shutdown and logoff seem untrappable by Perl on win. But it is in Cygwin. but i cannot switch to it
[choroba]: It has the widest rear seats space available in the same price category - needed for the 3 kids.
Discipulus families growth is related to price of cars nowadays..
[choroba]: price of anything, unfortunately

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2017-01-17 09:39 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (154 votes). Check out past polls.