in reply to Need 2 Regex's

Well ... a regex will really not help you with either problem (if truly identifying jpg/png/gif files and preventing name collisions in a multiprocess environment are your goals).

A valid jpg/png/gif file does not need one of those extensions and many times I've had users upload a .doc file with a .gif extension (I have no idea why). To properly identify file type you want File::Mimeinfo.

For #2, you may run into a a classic race condition (especially if you're going through a web server). To ensure non-colliding file names, something like a GUID (Data::GUID) appended to the end of each file (or using File::Basename to append the GUID before the suffix) would work.

-derby