I am still reading through your code, but the first thing i notice is:
in reply to What is the problem of subroutine "make_file" in my code?
is probably not doing what you intended. You probably mean the following:
my @Motif = split(//,'$origin[$y]'); # This is a loop to get the motif
+ template from origin8
(note the missing single-quotes)
# This is a loop to get the motif template from origin8
my @Motif = split(//,$origin[$y]);
Also it might help if you give us a short bit of the long_sequences.txt so we can run your code.