in reply to Unique filename

here's what I use, there may be "race condition" issues with it but I've had it in production for a couple of years with no problems:
$filename="/data/base_file."; $x=0; $x++ while (-e $filename.$x); $realfile=$filename.$x;