use warnings; use strict; open (my $file, '>', "testendings") or die "unable to open testendings for write! $!"; print $file "test\n"; close $file; print "Binary file created: 74 65 73 74 0D 0A\n"; open (my $infile, '<', "testendings") or die "unable to open testendings for read! $!"; my $in =<$infile>; close $infile; print "input as read by normal string IO: $in"; print "Length in bytes of input var as read is: ".length($in)," bytes\n"; $in =~ s/(.)/sprintf("%02X ",ord($1))/seg; print "$in\n"; print "note: when using Perl text read, the 0x0D was deleted!\n"; __END__ Binary file created: 74 65 73 74 0D 0A # 0D=>CR 0A=>LF input as read by normal string IO: test Length in bytes of input var as read is: 5 bytes 74 65 73 74 0A note: when using text read, the 0x0D was deleted!