Data::Scan - Stackfree arbitrary data scanner
version 0.009
use strict;
use warnings FATAL => 'all';
use Data::Scan;
use Data::Scan::Impl::Printer; # A Data::Printer implementation example
my $this = bless([ 'var1', 'var2', {'a' => 'b', 'c' => 'd'}, \undef, \\undef, [] ], 'TEST');
my $consumer = Data::Scan::Impl::Printer->new;
Data::Scan->new(consumer => $consumer)->process($this);
Data::Scan is a stackfree scanner of arbitrary data. It has no other intelligence but scanning its arguments and asking for a consumer to deal with every item.
A object instance that is consuming the Data::Scan::Role::Consumer role. Data::Scan::Printer is an example of an implementation consuming this role.
Instantiate a new Data::Scan object. Takes as parameter a required consumer, that is consuming the Data::Scan::Role::Consumer role.
Scan over all items in @arguments and will call the consumer with these five methods/signatures:
- $consumer->dsstart(Any @arguments)
-
Indicates to the consumer that scanning is starting. All initial arguments are sent to this method. Return value is ignored.
- $consumer->dsopen(Any $item)
-
Indicates to the consumer that an unfold of $item is starting. Return value is ignored.
- $consumer->dsread(Any $item)
-
Indicates to the consumer that he should take over $item. If the consumer is deciding to unfold it (typically when this is an ARRAY or a HASH reference), it should return an array reference containing the unfolded content. Anything but an an array reference means it has not been unfolded.
The consumer has full control on the workflow and can decide to unfold or not whatever is meaningful to him.
- $consumer->dsclose(Any $item)
-
Indicates to the consumer that an unfold of $item is ending. Return value is ignored.
- $consumer->dsend()
-
Indicates to the consumer that scanning is ending. Return value of consumer->end() will be the return value of $self->process(@arguments).
Data::Scan::Role::Consumer, Data::Scan::Printer
Please report any bugs or feature requests through the issue tracker at https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Scan. You will be notified automatically of any progress on your issue.
This is open source software. The code repository is available for public review and contribution under the terms of the license.
https://github.com/jddurand/data-scan
git clone git://github.com/jddurand/data-scan.git
Jean-Damien Durand <jeandamiendurand@free.fr>
Mohammad S Anwar <mohammad.anwar@yahoo.com>
This software is copyright (c) 2016 by Jean-Damien Durand.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.