Even better lets do $counter a global variable.

Quote:
{
my $counter = 0;
sub getFreeFilename {
while(1) {
my $file_name = sprintf("%s_%s_%s.html",$$,$^T,$counter++);
return $file_name if not -e $file_name;
};
}
}
Since all this code is inside { }, the $count is just visible inside { } and will exist while the subroutine is existing (+- as a static variable in C++). So no real loop is necessary.