Variable: tramp-perl-encode

tramp-perl-encode is a variable defined in tramp-sh.el.gz.

Value

"%p -e '\nuse strict;\n\nmy %%trans = do {\n    my $i = 0;\n    map {(substr(unpack(q(B8), chr $i++), 2, 6), $_)}\n      split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/);\n};\nmy $data;\n\n# We read in chunks of 54 bytes, to generate output lines\n# of 72 chars (plus end of line)\nwhile (read STDIN, $data, 54) {\n    my $pad = q();\n\n    # Only for the last chunk, and only if did not fill the last\n    # three-byte packet\n    if (eof) {\n        my $mod = length($data) %% 3;\n        $pad = q(=) x (3 - $mod) if $mod;\n    }\n\n    # Not the fastest method, but it is simple: unpack to binary string, split\n    # by groups of 6 bits and convert back from binary to byte; then map into\n    # the translation table\n    print\n      join q(),\n        map($trans{$_},\n            (substr(unpack(q(B*), $data) . q(00000), 0, 432) =~ /....../g)),\n              $pad,\n                qq(\\n);\n}' %n"

Documentation

Perl program to use for encoding a file.

Format specifiers are replaced by tramp-expand-script, percent characters need to be doubled.

Source Code

;; Defined in /usr/src/emacs/lisp/net/tramp-sh.el.gz
;; This script contributed by Juanma Barranquero <lektu@terra.es>.
(defconst tramp-perl-encode "\
%p -e '
use strict;

my %%trans = do {
    my $i = 0;
    map {(substr(unpack(q(B8), chr $i++), 2, 6), $_)}
      split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/);
};
my $data;

# We read in chunks of 54 bytes, to generate output lines
# of 72 chars (plus end of line)
while (read STDIN, $data, 54) {
    my $pad = q();

    # Only for the last chunk, and only if did not fill the last
    # three-byte packet
    if (eof) {
        my $mod = length($data) %% 3;
        $pad = q(=) x (3 - $mod) if $mod;
    }

    # Not the fastest method, but it is simple: unpack to binary string, split
    # by groups of 6 bits and convert back from binary to byte; then map into
    # the translation table
    print
      join q(),
        map($trans{$_},
            (substr(unpack(q(B*), $data) . q(00000), 0, 432) =~ /....../g)),
              $pad,
                qq(\\n);
}' %n"
  "Perl program to use for encoding a file.
Format specifiers are replaced by `tramp-expand-script', percent
characters need to be doubled.")