Perl? Nah. BASH!
First, since the format is XXXX-dddd, you can echo the filename to "cut" and use a shell escape to put the XXXX part into another shell variable. Then echo the filename into the file specified in that variable.
Wrap a for loop for all files around it, and you got yourself a oneliner!