I'd suspect the main slowdown is the system("mkdir ...") call. Assuming you have significantly less than 5 million car manufacturers you'd probably be better off
a) testing if the directory exists before attempting to create it
b) using the perl built-in mkdir command
c) cache this info. IOW, don't try to recreate a directory you've already created before. The difference between system and mkdir and stat is quite vast, but in this situation it completely dwarfed by the sheer amount of unnecessary calls you'd make. update: this is the important suggestion. you can ignore the rest for this particular problem.