#!/usr/bin/perl # For pulling IP address out of qmail headers. Matches # first "Received:" line with an IP address in it. # # Note that origip.pl extracts the IP address of the "last hop", so you # may want to customize it to skip the first X hops depending on your # local setup. # # by Chris Hardie # chris@summersault.com @msg = ; foreach $line ( @msg ) { chop $line; if (($line =~ m/^Received/) && ($line =~ m/(\d+\.\d+\.\d+\.\d+)/)) { $REMOTEIP = $1; last; } } print STDOUT ( $REMOTEIP );