in reply to Why doesnt it work

Be careful for those <<END... print statements. I noticed that sometimes programmers will add some whitespace without noticing, i.e.,
print <<end_of_stuff; [..some stuff..] end_of_stuff
That second 'end_of_stuff' screws up because of the prefixed space. Also, you probably check this already, but did you convert you're line endings to Unix style and verify that your ftp program didn't make any changes? I once had a friend who couldn't get his scripts to work and then we discovered his ftp client kept adding /r to the end of each line.