With this code:
#!/usr/bin/perl
use warnings FATAL => 'all';
use strict;
use MIME::QuotedPrint;
my $encoded = "=4E=6F=74=65=73=0A=4E=6F=74=65=73=20=6C=69=6E=65=20=32";
print decode_qp($encoded);
my $decoded = "Imported today";
$encoded = encode_qp($decoded);
print "\n$encoded\n";
The first print statement gives exactly what I was expecting, but the second gives Imported today=
instead of =49=6D
etc.
What am I doing wrong?
The documentation of MIME::QuotedPrint says (emphasis mine):
Each non-printable character (as defined by English Americans) is represented by a triplet consisting of the character "=" followed by two hexadecimal digits.
And indeed, in the distribution's tests, you can find
# plain ascii should not be encoded
["", ""],
["quoted printable" =>
"quoted printable=\n"],
So, you're not doing anything wrong, your expectation is wrong.
To get the expected output, you don't need any module:
my $encoded = join "", map sprintf("=%02X", ord), split //, 'Imported today';