Data::Translate - Translate string data between a few patterns (binary,decimal,ascii,hex)
SYNOPSIS
use Data::Translate;
$data=new Translate;
# Example, translating from hex to Ascii
# $s receives the status of the operation
@hh=qw(64 65 6e 61 6f);
($s,@ha)=$data->h2a(@hh);
print join('',@ha),"\n"; ## will output "denao"
DESCRIPTION
This module is intended to translate data between a few patterns.
Basicly, it is a ease mode to pack/unpack stuff.
Imagine, you have a script that treats hex data, and you
need to see the values, in other format, like decimal,
binary or even ascii.
This module implements a symplistic way to Translate values
smoothly returning the status of operation and values always
on a string.
You may translate at this point:
- ascii to binary
- ascii to decimal
- ascii to hex
- decimal to ascii
- decimal to binary
- decimal to hex
- binary to ascii
- binary to decimal
- binary to hex
- hex to binary
- hex to decimal
- hex to ascii
Please, head to test.pl for additional examples.
The functions you'll call, are defined as the first
byte of each data type.
If you want to translate from binary to hex, you'll
use the function b2h, and if you want to translate
from ascii to decimal, you'll use a2d, and so on.
->new
Creates a new instance of Translation.
eg.: $data=new Translate;