ftumsh has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/bin/perl -w use strict; use diagnostics; use File::Temp(); use File::Copy; my $FH = File::Temp->new ( TEMPLATE => 'tmpXXXXXXXXXX', SUFFIX => '.xml_out', DIR => '/tmp', UNLINK => 1 ); $FH->autoflush(1); binmode( $FH, ':crlf' ); print $FH "Hello World\n"; my $tgt_file = '/tmp/JD'; copy ( $FH->filename, $tgt_file ); require Digest::MD5; my $md5; $FH->seek(0,0); $md5 = Digest::MD5->new->addfile( $FH ); print 'by FH: ',$md5->hexdigest,"\n"; my $md52; open(FILE, $tgt_file) or die "Can't open : $!"; binmode(FILE); $md52 = Digest::MD5->new->addfile(*FILE); close FILE; print 'by FILE1: ',$md52->hexdigest,"\n"; my $md53; open(FILE, $FH->filename) or die "Can't open : $!"; binmode(FILE); $md53 = Digest::MD5->new->addfile(*FILE); close FILE; print 'by FILE2: ',$md53->hexdigest,"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: binmode layer and seek
by moritz (Cardinal) on Jul 08, 2008 at 12:05 UTC | |
by ftumsh (Scribe) on Jul 08, 2008 at 13:31 UTC | |
by moritz (Cardinal) on Jul 08, 2008 at 13:46 UTC | |
|
Re: binmode layer and seek
by Anonymous Monk on Jul 08, 2008 at 11:46 UTC |