Use File::chdir instead of chdir

Perls chdir() is global, and we have to make sure that we restore it
once we're done with it. This can be much simplified by using
File::chdir. By using a local $CWD the effect is the same but there's no
need to clean up afterwards.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>