To see if MSN is open, you could use Win32::API (though I have no idea how to use that module. Probably Matt Austin could help you there). You might be able to get a list of process IDs and see if msnmsgr.exe is running.
But for your other question, how to add 1 to a variable after a loop:
Code:
my $variable = 0; # just some starting number<br />while (1) {<br /> $variable++; # add one<br /><br /> # Maybe do something after 500 loops?<br /> if ($variable == 500) {<br /> print "\aThe 500th loop has been reached!\n";<br /> }<br />}