That is bad enough to rate a mention in the FAQ perhaps?

-----Original Message-----
From: Sean M. Burke [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 20, 2002 6:33 PM
To: Hugh S. Myers; [EMAIL PROTECTED]
Subject: RE: perlfaq5: How can I read in an entire file all at once?
(`type filename` is bad!)


At 17:59 2002-03-20 -0700, Hugh S. Myers wrote:
>We could concoct a test file and give it a go I suppose? Microsoft
>specifically says that type is for text files so I'm more than a little
>dubious...


OK, you twisted my arm.
AND IT BROKE.  Well, the test broke. Here is the test:

use strict;
use warnings;

my $temp = "out.dat";
open(OUT, ">$temp") or die $!;
binmode(OUT);
my $dat = join '', map chr($_), 0 .. 255, 0 .. 255, reverse(0 .. 255);
print OUT $dat;
close(OUT);

sleep 1;

my $x1;
{
   local $/;
   open(IN, "<$temp") or die $!;
   binmode(IN);
   $x1 = <IN>;
   close(IN);
}
print '', ($x1 eq $dat) ? "ok1\n" : "BAD1\n";

my $x2;
{
   local $/;
   open(IN, "<$temp") or die $!;
   #### NO BINMODE
   $x2 = <IN>;
   close(IN);
}
print '', ($x2 eq $dat) ? "ok2\n" : "BAD2\n";


my $x3 = `type $temp`;
print '', ($x3 eq $dat) ? "ok3\n" : "BAD3\n";
__END__


The result:

C:\WINDOWS\Desktop\Torgo>perl -w type_test.pl
ok1
BAD2
BAD3


C:\WINDOWS\Desktop\Torgo>perl -V
Summary of my perl5 (revision 5 version 6 subversion 1) configuration:
   Platform:
     osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
     uname=''
     config_args='undef'
     hint=recommended, useposix=true, d_sigaction=undef
     usethreads=undef use5005threads=undef useithreads=define 
usemultiplicity=define
     useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
   Compiler:
     cc='cl', ccflags ='-nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE 
-DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS 
-DPERL_MSVCRT_READFIX',
     optimize='-O1 -MD -DNDEBUG',
     cppflags='-DWIN32'
     ccversion='', gccversion='', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
     d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=4
     alignbytes=8, usemymalloc=n, prototype=define
   Linker and Libraries:
     ld='link', ldflags ='-nologo -nodefaultlib 
-release  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
     libpth="C:\Perl\lib\CORE"
     libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib 
winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
     perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib wsock32.lib mpr.lib 
winmm.lib  version.lib odbc32.lib odbccp32.lib msvcrt.lib
     libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
   Dynamic Linking:
     dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib 
-release  -libpath:"C:\Perl\lib\CORE"  -machine:x86'


Characteristics of this binary (from libperl):
   Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT 
PERL_IMPLICIT_SYS
   Locally applied patches:
         ActivePerl Build 628
   Built under MSWin32
   Compiled at Jul  4 2001 15:41:05
   %ENV:
     PERL5LIB="c:\plib"
     PERLDOC_CLASS="Pod::Tree::RTF"
     PERLDOC_PAGER="towrite"
   @INC:
     c:\plib
     C:/Perl/lib
     C:/Perl/site/lib
     .



--
Sean M. Burke    [EMAIL PROTECTED]    http://www.spinn.net/~sburke/


Reply via email to