The earlier suggestions for
use strict; are good ones. It helps you catch typos in your code. I'm going to go out on a limb and guess that there's a typo near this line:
{$line=$line.",".$short;}
And that you may really have something else, like this:
{$line=$lin.",".$short;} # Oops, $lin should be $line
If you didn't do this originally, try to cut-and-paste code directly into the web browser when you submit a code sample. That way we can see if there are any typos in the original code. Your code, as you've written it here, seems to work for me.
buckaduck