Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^6: Error binmode() on unopened filehandle

by jo37 (Deacon)
on May 03, 2020 at 14:54 UTC ( [id://11116389]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Error binmode() on unopened filehandle
in thread Error binmode() on unopened filehandle

My last example was without the special DATA file handle and shows that my $binary = <$fh> will read the data from $fh up to and including the first appearance of $/. Using binmode on a file handle does not change this behaviour.

You may check if:

  • your data really does not contain a record separator
  • the generated base64 data, when decoded, resembles the original file

EDIT: Here is another:

#!/usr/bin/perl use strict; use warnings; use constant RANDFILE => "rand.dat"; system "dd if=/dev/urandom of=" . RANDFILE . " bs=1k count=64"; open my $fh, '<', RANDFILE or die; binmode $fh; my $binary = <$fh>; print "got: ", length($binary), "\n";

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116389]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 18:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found