Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW


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.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2020-10-01 00:15 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (172 votes). Check out past polls.