I don't think you know what a boot partition is. Suggesting that a novice alter his boot partition is tantamount to suggesting he play Russian Roulette with all chambers loaded. Perhaps you meant to say root directory (although where the file resides doesn't really matter).
use warnings;
use strict;
my $max_attempts = 5;
# for windows, replace cat with type
my $reboot_number = `cat reboot_attempts` || 0;
if ($reboot_number++ < $max_attempts) {
`echo $reboot_number > reboot_attempts`;
print "Rebooting...\n";
# code to make computer reboot here
}