in reply to Create a Binary file using perl

Please help me to create a binary file from txt file(i have sample.txt) it has to convert into binary file.

"Binary file" is a way to refer to anything that is not a plain text file, and in some sense they're the same thing under some platforms. Thus you must have in mind some specific kind of binary file, but you're failing to tell you us what it is or maybe you even don't really know. Thus one way to answer your question would be: just add some random non ascii chars to your text file. (I'm reasoning all out of the unicode realm which makes things even slightly more complex, and I don't know much.)