LINUX.ORG.RU

Ответ на: joy4eg от Cave-Canem
    pack TEMPLATE,LIST
            Takes a LIST of values and converts it into a string using the
            rules given by the TEMPLATE. The resulting string is the
            concatenation of the converted values. Typically, each converted
            value looks like its machine-level representation. For example, on
            32-bit machines an integer may be represented by a sequence of 4
            bytes, which will in Perl be presented as a string that's 4
            characters long.

            The TEMPLATE is a sequence of characters that give the order and
            type of values, as follows:
<...>
                V  An unsigned long (32-bit) in "VAX" (little-endian) order.

Всё остальное тривиально, это просто краткая запись такого кода:

my $input = <STDIN>;
my $value = hex($input);
my $packed = pack("V", $value);
print $packed;
anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.