NAME

Magic::ConversionChain - Create permanent conversion chains

VERSION

Version 0.01

SYNOPSIS

NOTE I created this module to assist me with another and found it so useful and different I decided to release it, I am still actively working on it and input is welcome, but be warned it is no where near complete.

Magic::ConversionChain Allows you to create data manipulation 'objects' for when you are working in a situation where you need to shift one type of data into another or adjust text in specific ways, it was mainly created because the owner hates pack, but it can be very useful for padding data binary/bytes/hex conversions and more.

Here is a code snippet for converting a standard number into an equivlent that would be generated by a signed int32 in perl, the output will be returned in hex.

use Magic::ConversionChain;

my $padTest = Convert::Permanent->new({
 conversion => [ qw( i32s hex ) ],
});

my $result = $n2h->proc('34243');

# result = c3850000

I will continue expanding this module including sha, md5 and the entire of pack's data types usable in what I class to be a far more friendly way.

SUBROUTINES/METHODS

new

Create a new basic object.

proc

Feed data into the filter and get the conversion returned.

input

Configure an input filter for the object, if left unset it will be assumed the object is an 'input' for the conversion chain, you will be able to submit data for conversion via:

$conv->proc($data);

i32s

Convert an object into the equivalent of an signed int32.

Requires: 1 argument

i32u

Convert an object into the equivalent of an unsigned int32.

Requires: 1 argument

i32u_bigendian

Convert an object into the equivalent of an unsigned int32 (Big Endian).

Requires: 1 argument

output

Internal conversion methods

hex

Convert data into hex.

pad_right

Required arguments: 2

Syntax: pad_right(LENGTH,PAD_CHARACTER)

Pad the right hand side of the supplied data with ARG1 upto a length of ARG0.

pad_left

Required arguments: 2

Syntax: pad_left(LENGTH,PAD_CHARACTER)

Pad the left hand side of the supplied data with ARG1 upto a length of ARG0.

truncate_right

Truncate text treating the right hand side of the data block as the start point.

Required arguments: 1

Syntax: truncate_right(10)

truncate_left

Truncate text treating the left hand side of the data block as the start point.

Internal callable functions

These are used internally by the module, do not call them directly unless you have a very good reason!

cmddat

Receive information back or sub references for data types.

AUTHOR

Paul G Webster, <daemon at cpan.org>

BUGS

Please report any bugs or feature requests to bug-convert-permanent at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Convert-Permanent. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Magic::ConversionChain

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2014 Paul G Webster.

This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

* Neither the name of Paul G Webster's Organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.