in reply to Help with RC4

Heard of binmode? Sounds very much like you need to apply it.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re^2: Help with RC4
by jmamer (Initiate) on Jul 26, 2004 at 05:56 UTC
    Thank you! I'd read that binmode wasn't needed on *nix systems -- apparently, I over interpreted what I read. Seems that what I needed was a combination of undef $/; and binmode(INFILE); and then $plaintext = <INFILE>. Binmode was also needed for the output file. thank you, thank you, thank, you! j.
      Hmm, binmode should not be needed on Linux (or Unix.) From perldoc -f binmode:
      Arranges for FILEHANDLE to be read or written in "binary" or "text" mode on systems where the run-time libraries distinguish between binary and text files..
      But the libraries on Unix-like systems make no such distinction. I'm guessing that the measures you took worked around the bug I mentioned below.

      "Even if you are on the right track, you'll get run over if you just sit there." - Will Rogers
        From `perldoc -f binmode', perl 5.8.4, emphasis mine
        On some systems (in general, DOS and Windows-based systems) binmode() is necessary when you're not working with a text file. For the sake of portability it is a good idea to always use it when appropriate, and to never use it when it isn't appropriate. Also, people can set their I/O to be by default UTF-8 encoded Unicode, not bytes.

        In other words: regardless of platform, use binmode() on binary data, like for example images.

        images, executables, zipfiles, tarballs, encrypted ...

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.