binmode clobbers :via

D

dearcilla

I'm new to perl, and tend to find it frustrating. I thought PerlIO
layers were a neat feature, but I can't do anything with them.

When I write something like this:

open(my $fileHandle, ">:via(Base64)", $name . '.txt') or die "$!";
binmode($fileHandle);
my $binaryData = "Hi there";
print $fileHandle $binaryData;

I get a file with "Hi there", not "SGkgdGhlcmU=". Using the CBC layer
results in an analogous problem.

I can go into more detail if necessary, but I'm trying to keep this
short, since many people don't like to read long posts.
 
X

xhoster

dearcilla said:
I'm new to perl, and tend to find it frustrating. I thought PerlIO
layers were a neat feature, but I can't do anything with them.

When I write something like this:

open(my $fileHandle, ">:via(Base64)", $name . '.txt') or die "$!";

Hey, I want this to be converted to Base64.
binmode($fileHandle);

Oops, now I want it to be :raw.

How can it be both? It can't. So it takes the last one you threw at it.

my $binaryData = "Hi there";
print $fileHandle $binaryData;

I get a file with "Hi there", not "SGkgdGhlcmU=". Using the CBC layer
results in an analogous problem.

I can go into more detail if necessary, but I'm trying to keep this
short, since many people don't like to read long posts.

Patient: "Doc, it hurts when I do this."
Doc: "Then don't do that."

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top