String-HexConvert/0000755000175000017500000000000011477741063014555 5ustar andreashandreashString-HexConvert/lib/0000755000175000017500000000000011466263717015326 5ustar andreashandreashString-HexConvert/lib/String/0000755000175000017500000000000011477734642016576 5ustar andreashandreashString-HexConvert/lib/String/HexConvert.pm0000644000175000017500000000477111477740700021222 0ustar andreashandreashpackage 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 # # 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 =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 =head1 AUTHOR Andreas Hernitscheck ahernit(AT)cpan.org =head1 LICENSE You can redistribute it and/or modify it under the conditions of LGPL. =cut String-HexConvert/t/0000755000175000017500000000000011477740402015014 5ustar andreashandreashString-HexConvert/t/01_compile.t0000755000175000017500000000033611475467226017146 0ustar andreashandreash#!/usr/bin/perl use lib '../lib'; use strict; use warnings; use Test::More tests => 1; my @modules = qw( Exporter ); foreach my $module (@modules) { eval " use $module "; ok(!$@, "$module compiles"); } 1; String-HexConvert/t/02_conv.t0000755000175000017500000000043311477741043016454 0ustar andreashandreash#!/usr/bin/perl use lib '../lib'; use strict; use warnings; use Test::More tests => 2; use String::HexConvert ':all'; is(ascii_to_hex("hello world"), "68656c6c6f20776f726c64", "ascii_to_hex"); is(hex_to_ascii("68656c6c6f20776f726c64"), "hello world", "hex_to_ascii"); String-HexConvert/Makefile.PL0000644000175000017500000000377411477740116016540 0ustar andreashandreash# -*- mode: perl; c-basic-offset: 10; indent-tabs-mode: nil; -*- use 5.006; #Pod::Abstract use ExtUtils::MakeMaker; WriteMakefile1( LICENSE => 'lgpl', MIN_PERL_VERSION => '5.006', META_MERGE => { resources => { repository => 'http://github.com/andreashe/Perl-Module-String-HexConvert', }, }, BUILD_REQUIRES => { 'Test::More' => 0, }, 'NAME' => 'String::HexConvert', 'VERSION_FROM' => 'lib/String/HexConvert.pm', 'PREREQ_PM' => { 'strict' => 0, 'Exporter' => 0, }, 'INSTALLDIRS' => 'site', 'PL_FILES' => {}, 'AUTHOR' => 'Andreas Hernitscheck ', ); sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade. my %params=@_; my $eumm_version=$ExtUtils::MakeMaker::VERSION; $eumm_version=eval $eumm_version; die "EXTRA_META is deprecated" if exists $params{EXTRA_META}; die "License not specified" if not exists $params{LICENSE}; if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) { #EUMM 6.5502 has problems with BUILD_REQUIRES $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} }; delete $params{BUILD_REQUIRES}; } delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52; delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48; delete $params{META_MERGE} if $eumm_version < 6.46; delete $params{META_ADD} if $eumm_version < 6.46; delete $params{LICENSE} if $eumm_version < 6.31; delete $params{AUTHOR} if $] < 5.005; delete $params{ABSTRACT_FROM} if $] < 5.005; delete $params{BINARY_LOCATION} if $] < 5.005; WriteMakefile(%params); }