/usr/share/perl5/String/HexConvert.pm is in libtext-string-hexconvert-perl 0.01-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | package String::HexConvert; ## Converts ascii strings to hex and reverse
our $VERSION='0.01';
use strict;
use vars qw(@ISA @EXPORT %EXPORT_TAGS $VERSION);
use Exporter;
@ISA = qw(Exporter);
%EXPORT_TAGS = ( all => [qw(
hex_to_ascii
ascii_to_hex
)] );
Exporter::export_ok_tags('all');
# It is a wrapper around pack and unpack of perl to convert a string of hex digits
# to ascii and other way around.
#
# SYNOPSIS
# ========
#
# use String::HexConvert ':all';
#
# print ascii_to_hex("hello world"); # writes: 68656c6c6f20776f726c64
#
# print hex_to_ascii("68656c6c6f20776f726c64"); # writes: hello world
#
#
#
# SEE ALSO
# ========
# pack, unpack, L<Data::Translate>
#
# LICENSE
# =======
# You can redistribute it and/or modify it under the conditions of LGPL.
#
# WHY?
# ====
# In know the comments like "is that realy needed?". IMHO yes, because I forget the
# exact syntax and possibilities of pack and unpack but hex_to_ascii tells me directly
# what pack "H*" does.
#
# AUTHOR
# ======
# Andreas Hernitscheck ahernit(AT)cpan.org
# Converts pairs of hex digits to asci
sub hex_to_ascii { # $ascii ($hex)
my $s = shift;
return pack 'H*', $s;
}
# Converts a string to pairs of hex digits
sub ascii_to_hex { # $hex ($ascii)
my $s = shift;
return unpack("H*", $s);
}
1;
#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################
=head1 NAME
String::HexConvert - Converts ascii strings to hex and reverse
=head1 SYNOPSIS
use String::HexConvert ':all';
print ascii_to_hex("hello world"); # writes: 68656c6c6f20776f726c64
print hex_to_ascii("68656c6c6f20776f726c64"); # writes: hello world
=head1 DESCRIPTION
It is a wrapper around pack and unpack of perl to convert a string of hex digits
to ascii and other way around.
=head1 REQUIRES
L<Exporter>
=head1 METHODS
=head2 ascii_to_hex
my $hex = ascii_to_hex($ascii);
Converts a string to pairs of hex digits
=head2 hex_to_ascii
my $ascii = hex_to_ascii($hex);
Converts pairs of hex digits to asci
=head1 WHY?
In know the comments like "is that realy needed?". IMHO yes, because I forget the
exact syntax and possibilities of pack and unpack but hex_to_ascii tells me directly
what pack "H*" does.
=head1 SEE ALSO
pack, unpack, L<Data::Translate>
=head1 AUTHOR
Andreas Hernitscheck ahernit(AT)cpan.org
=head1 LICENSE
You can redistribute it and/or modify it under the conditions of LGPL.
=cut
|