in reply to Warning is right or not ?

Thanks to RichardK's comment, I fixed my typo and now the code is running without any warning.

return $data[$count-1],"\n";

I removed comma and newline that I used in print to test the data and the warning disappeared too. Thanks for your all helps.