readdir is not my friend. If you use File::Find, you don't have to mess with relative vs. absolute pathnames. You can use $File::Find::name, which is a complete pathname. You don't have to worry about '..' and '.'. Etc. etc. Quite untested:
use File::Find;
find(\&wanted, '/temp_gif');
sub wanted {
return unless /^\d+\.gif$/i;
(my $new_name = $File::Find::name)
=~ s/(\d+)\.gif$/($1+398) . 'GIF'/ei;
rename($File::Find::name, $new_name) or die $!;
}