If you wanna delve more into the subject, read the material AcidHawk gave you. But just for the matter, to erase the linebreak use chop($data = <>); (You can also use chomp instead. chomp erases the last character only if it's a newline. chop erases the last character no matter what.