Reading the Federal Register with Perl

In case you're curious:

% grep -rli assassin federal_register | wc -l

That's 50 mentions of "assassin" in the US Federal Register since early 2000. There's some interesting stuff buried in this publication.

Recently I wrote a post about more Americans giving up citizenship than reported. While I don't have exact numbers (they're hard to find), I managed to put together some information that seems to show that far more Americans are giving up citizenship than the Federal Register reports, but I'll skip the background.

Basically, I decided to download the entire Federal Register in XML format (it's in the public domain, too). Unfortunately, this snippet of code is not going in the book.

It didn't make it into the book because:

  • It's bloody slow
  • And what do you do with the damned thing?

The XML format is a bit clumsy and, well, I'm hardly going to say "this is code to count how many Americans renounce their citizenship every year", am I?

Regardless of my intentions, I suspect that would have been as welcome as a nun in a brothel. Still, the Federal Register has lots of interesting data about all sorts of subjects.

Please note that this code is to get daily updates. For past years, you can go to the Federal Register Website and download .zip files containing an entire year of reports. That's much faster than using this script.

Leave a comment

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book!