have you tried printing the string INSIDE the function??
"abc####123####-6####20111112 ..." is this what it printed?
print "outside "+$str; #this prints "0"
and if i remove sub keyword then it gives me compilation error
so do confirm your output inside the func