in reply to Split returns UPTO last non-blank field

Try changing my @ray = split(/~/,$tst_str); to my @ray = split(/~/,$tst_str,-1);