1 2 3
while(read $handle, my $buffer, 57){ $b64 .= encode_base64($buffer); # default trailer "\n" }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use strict;
use File::Slurp qw(write_file read_file);
use MIME::Base64;
use Data::Dumper;
write_file( 'base64_test.txt', <<'END_TEXT' );
Beispielstext für Base64
aaaaaaaaaaaa
bbbbbbbbbbbb
cccccccccccc
END_TEXT
my $encoded = encode_base64( read_file('base64_test.txt') );
print Data::Dumper->Dump( [ $encoded, decode_base64($encoded) ], [ qw/encoded decoded/ ] );