#!/usr/bin/perl -wT # population.pl use strict; use Untaint; use LWP::UserAgent; my $counter = untaint(qr(.*\.dat$), $ARGV[0]); my $ua = new LWP::UserAgent; $ua->agent("GetCount/0.1"); my $req = new HTTP::Request GET => 'http://www.census.gov/cgi-bin/ipc/popclockw'; $req->header(Accept => "text/html"); my $res = $ua->request($req); if ($res->is_success) { my $html = $res->content; (my $num = $html) =~ s!^.*

(.*?)

.*$!$1!si; open(LOG, $counter) || die "Can't read counter. $!"; my $log = ; close LOG; ($num = $num) =~ s!,!!g; $num = $num-$log; 1 while $num =~ s!^(\d+)(\d{3})!$1,$2!; print $num; } else { print "[trouble calculating]"; }