To get it to do what you request, change the script to this:
---START CUT&PASTE NEXT LINE
#!/usr/bin/perl
$server = "change.irc.server";
$port = 6667;
$nick = "PickANick";
$realname = "Just passing through...";
use IO::Socket;
use DBI;
$dbname = "yourdbname";
$dbhost = "yourhost";
$dbuser = "yourdbuser";
$dbpasswd = "yourdbpassword";
$vbdb=DBI->connect("dbi:mysql:".$dbname.":".$dbhost,$dbuser, $dbpasswd);
@channels = ('#Newsdesk','#Education','#Politics-&-Govt','#Military-&-Vets','#DallasMavericks','#TexasRangers','#Houston Texans','#YouthSports','#bits-&-bytes','#Daily-Web.Info','#technology','#religion-&-faith','#business-&-finance','#health','#SportsPage','#DallasStars','# DallasCowboys','#entertainment');
$irc=IO::Socket::INET->new( PeerAddr=>$server, PeerPort=>$port, Proto=>'tcp')or die "$server: $@\n";
print $irc "USER $nick $nick $nick :$realname\n";
print $irc "NICK $nick\n";
while(@channels) {
$channel = shift @channels;
print $irc "JOIN $channel\n";
while(defined($in=<$irc>)){
chop($in);
if($in=~/PING

.*)/){
print $irc "PONG $1\n";
}
@field = split(/ /,$in);
if ($field[1] eq "353") {
@users = split(/:/,$in);
$users[2] =~ s/@//g;
$users[2] =~ s/\+//g;
$users[2] =~ s/ PutNickHere//; # <----Don't forget!
@nicks = split(/ +/,$users[2]);
$sql = $vbdb->prepare("UPDATE ircstat SET channelusers=$#nicks, channelnicks=\"$users[2]\" WHERE channelname=\"$field[4]\"");
$sql->execute;
print $irc "PART $channel\n";
last;
}
}
}
close($irc);
-----END CUT&PASTE PREVIOUS LINE----
This runs considerably faster, 20 seconds for 18 channels instead of 3 minutes, but it does have drawbacks.
First, is whatever time interval you set the script to run via cron, thats how often this user is going to join/leave the channel. The more often you do it, the more annoying it is. The less often you do it, the more stale your data becomes.
If you have channel bots, make sure they do not do an on_join greet to this nick. It just increases the annoyance factor. Also make sure this nick is exempy from excessive join/part bans.
This script is an example of the axiom, "Be careful what you wish for, you may get it".