In case anyone else was interested in how to do this, I came up with this code. It performs the account substitution nicely, and seems to work well.
* Note: I placed this code into my old "topsites.cgi" file.
---------------------------------------------------
#!/usr/bin/perl
use CGI qw(:standard);
my $id = param('id');
print "Location:
http://www.mysite.com/in.php?id=$id\n\n";
print ("Content-type: text/html\n\n");
exit;
---------------------------------------------------
