need help reading/writing binary

Discussion in 'Perl' started by Steve Bennett, Aug 25, 2004.

  1. Can anyone suggest a good tutorial for reading
    and writing binary files in Perl or send me some tips or examples?
    I tried using pack and unpack and seek and read
    but things don't work as expected so I must be missing
    some subtle details.

    For example: I tried reading a .RAW image file (no header info) and
    writing it back out
    using seek read and print.
    It almost worked but any part of the image that was black
    threw things off. I suspect maybe the zeros (black) were somehow
    being interpreted as EOF or NUL or something.
    I also suspect that there are issues with word boundries I don't quite
    grasp.

    Thanks,
    -Steve
     
    Steve Bennett, Aug 25, 2004
    #1
    1. Advertising

  2. Steve Bennett

    Joe Smith Guest

    Steve Bennett wrote:

    > Can anyone suggest a good tutorial for reading
    > and writing binary files in Perl or send me some tips or examples?


    Most important: use binmode(). Use unpack() for reading, pack() for writing.

    Create a short program and post it to comp.lang.perl.misc (and not
    to comp.lang.perl) for suggestions.
    -Joe
     
    Joe Smith, Aug 25, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Gowans

    Reading/Writing pure binary files

    Daniel Gowans, May 27, 2004, in forum: VHDL
    Replies:
    2
    Views:
    5,275
  2. Louis
    Replies:
    6
    Views:
    1,111
    Sudsy
    Oct 15, 2003
  3. Daniel Moree

    Reading and Writing to Binary Files

    Daniel Moree, Nov 23, 2004, in forum: C++
    Replies:
    9
    Views:
    1,022
    Jonathan Mcdougall
    Nov 24, 2004
  4. Ron Eggler

    writing binary file (ios::binary)

    Ron Eggler, Apr 25, 2008, in forum: C++
    Replies:
    9
    Views:
    966
    James Kanze
    Apr 28, 2008
  5. Leslaw Bieniasz
    Replies:
    2
    Views:
    1,085
    Thomas J. Gritzan
    Jan 15, 2010
Loading...

Share This Page