in reply to automating linux commands in perl

You copy the files to your current directory, whatever that is at the moment. You probably should use
"/bin/cp -f $dirname/$file $dirname/malign.top".

daniel.