While the suggestions of File::Spec are spot on, the module is not without its problems. Its functionality is fine. Its interface, on the other hand, (which somehow tries to be OO but isn't really) gives me a headache whenever I try to figure out how to use it.
I reccomend Path::Class. It provides a much nicer object oriented interface that wraps the File::Spec functions underneath. It makes infinitely more sense, and is much more readable.
Once it's Turing complete, everything else is just syntactic sugar.