Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

crc-16

by PaulC (Initiate)
on Jun 12, 2001 at 20:53 UTC ( #87866=perlquestion: print w/replies, xml ) Need Help??

PaulC has asked for the wisdom of the Perl Monks concerning the following question:

i asked the previous crc-16 question, what ireally want to know is how to read in any type of file wihtout opening it, because if you try to open a .gif there is garbage, so I am still lost

Replies are listed 'Best First'.
(boo) Re: crc-16
by boo_radley (Parson) on Jun 12, 2001 at 21:05 UTC
    well, you can't read any file without opening it (At least, at the OS level...) .gif files are binary data, so it tends to look like garbage if you're expecting something readable...

    What are you expecting? Where does the CRC-16 come in?

    Are you just trying to get a checksum for a gif file, like to generate a list of duplicate images? you might try some MD5 routines, which will have a smaller chance of duplicate checksums (or "digests" as they're also called) for many files. If you're on a windows platform, set  binmode FILEHANDLE to read the file properly.

    Do you want to try to edit a gif file? You might try installing perlmagic.

    If this still doesn't describe what you want, try the following template :


    I would like to perform a/an( noun : operation or transformation) on a GIF file because I am trying to achieve ( noun : goal ). I have tried to ( list : things I have attempted), but they don't seem to work, because (list : results of attempts).
    Update : Nits annoy me. changed template to work with nouns.
      Did you mean s/noun/verb/g at the bottom?

      --
      $you = new YOU;
      honk() if $you->love(perl)

Re: crc-16
by lhoward (Vicar) on Jun 12, 2001 at 21:00 UTC
    There is no way to read a file without opening it.

    To you, the contents of a .gif file may look like garbage. But that is just because it was not intented to be read by a person (its in binary). Don't let the fact that you can't understand it (it looks like garbage to you) lead you believe that it isn't good, usable data.

    BTW, if you're processing a binary file on Windows, be sure to binmode it.

Re: crc-16
by THRAK (Monk) on Jun 12, 2001 at 20:59 UTC
    Type "binmode" in the search box to solve your problem. This will allow you to open and read binary files.

    -THRAK
    www.polarlava.com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://87866]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2019-09-20 01:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (253 votes). Check out past polls.

    Notices?