Prev: FAQ 4.72 How do I determine whether a scalar is a number/whole/integer/float?
Next: FAQ 8.1 How do I find out which operating system I'm running under?
From: sln on 11 Jun 2010 16:39 On Fri, 11 Jun 2010 12:48:17 -0500, John Bokma <john(a)castleamber.com> wrote: >Tad McClellan <tadmc(a)seesig.invalid> writes: > >> Use binmode on binary files. >> >> Do not use binmode on text files. > >/unless/ you want the data as it is on disk, for example to >calculate a check sum. > Semantics! You wouldn't create a check sum on a text file. Otherwise it wouldn't be a text file, it would be a binary file. -sln
From: John Bokma on 11 Jun 2010 17:07 sln(a)netherlands.com writes: > On Fri, 11 Jun 2010 12:48:17 -0500, John Bokma <john(a)castleamber.com> wrote: > >>Tad McClellan <tadmc(a)seesig.invalid> writes: >> >>> Use binmode on binary files. >>> >>> Do not use binmode on text files. >> >>/unless/ you want the data as it is on disk, for example to >>calculate a check sum. >> > Semantics! You wouldn't create a check sum on a text file. > Otherwise it wouldn't be a text file, it would be > a binary file. Is that so? So if I calculate a MD5 digest over a text file to check its integrity it magically becomes a binary file? Even if I add the checksum to the end of the text file, it still can be a text file. -- John Bokma j3b Hacking & Hiking in Mexico - http://johnbokma.com/ http://castleamber.com/ - Perl & Python Development
From: Uri Guttman on 11 Jun 2010 17:55 >>>>> "JB" == John Bokma <john(a)castleamber.com> writes: JB> sln(a)netherlands.com writes: >> On Fri, 11 Jun 2010 12:48:17 -0500, John Bokma <john(a)castleamber.com> wrote: >> >>> Tad McClellan <tadmc(a)seesig.invalid> writes: >>> >>>> Use binmode on binary files. >>>> >>>> Do not use binmode on text files. >>> >>> /unless/ you want the data as it is on disk, for example to >>> calculate a check sum. >>> >> Semantics! You wouldn't create a check sum on a text file. >> Otherwise it wouldn't be a text file, it would be >> a binary file. JB> Is that so? So if I calculate a MD5 digest over a text file to check its JB> integrity it magically becomes a binary file? Even if I add the checksum JB> to the end of the text file, it still can be a text file. it matters on winblows. if you just open a text file with no binmode and pass the handle to a checksum sub, it will not calculate a proper sum for the file itself. the cr/lf pairs will become newlines and the sum will be different than if done on the raw file. uri -- Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: sln on 11 Jun 2010 20:12 On Fri, 11 Jun 2010 16:07:01 -0500, John Bokma <john(a)castleamber.com> wrote: >sln(a)netherlands.com writes: > >> On Fri, 11 Jun 2010 12:48:17 -0500, John Bokma <john(a)castleamber.com> wrote: >> >>>Tad McClellan <tadmc(a)seesig.invalid> writes: >>> >>>> Use binmode on binary files. >>>> >>>> Do not use binmode on text files. >>> >>>/unless/ you want the data as it is on disk, for example to >>>calculate a check sum. >>> >> Semantics! You wouldn't create a check sum on a text file. >> Otherwise it wouldn't be a text file, it would be >> a binary file. > >Is that so? So if I calculate a MD5 digest over a text file to check its >integrity it magically becomes a binary file? Even if I add the checksum >to the end of the text file, it still can be a text file. Haha! Its funny but after you validate the integrity with a checksum, it reads different when read in text mode depending on the OS. Semantics.. -sln
From: Tad McClellan on 11 Jun 2010 21:31
sln(a)netherlands.com <sln(a)netherlands.com> wrote: > On Fri, 11 Jun 2010 12:48:17 -0500, John Bokma <john(a)castleamber.com> wrote: > >>Tad McClellan <tadmc(a)seesig.invalid> writes: >> >>> Use binmode on binary files. >>> >>> Do not use binmode on text files. >> >>/unless/ you want the data as it is on disk, for example to >>calculate a check sum. >> > Semantics! You wouldn't create a check sum on a text file. I create checksums on text files fairly often. > Otherwise it wouldn't be a text file, it would be > a binary file. Nonsense! What makes you think that taking a checksum changes a file's type? -- Tad McClellan email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/" The above message is a Usenet post. I don't recall having given anyone permission to use it on a Web site. |