NAME
Tags::Utils::Preserve - Class to check if content in element is preserved?
SYNOPSIS
use Tags::Utils::Preserve;
my $obj = Tags::Utils::Preserve->new(%params);
my $preserved_flag = $obj->begin($element);
my ($preserved_flag, $prev_preserved_flag) = $obj->begin($element);
my $preserved_flag = $obj->end($element);
my ($preserved_flag, $prev_preserved_flag) = $obj->end($element);
my $preserved_flag = $obj->get;
my ($preserved_flag, $prev_preserved_flag) = $obj->get;
$obj->reset;
$obj->save_previous;
METHODS
new
my $obj = Tags::Utils::Preserve->new(%params);
Constructor.
preserved
Preserved elements.
Default value is [].
Returns instance of object.
begin
my $preserved_flag = $obj->begin($element);
my ($preserved_flag, $prev_preserved_flag) = $obj->begin($element);
Process for begin of element.
Returns preserved flag in scalar context.
Returns preserved flag and previous preserved flag in array context.
end
my $preserved_flag = $obj->end($element);
my ($preserved_flag, $prev_preserved_flag) = $obj->end($element);
Process for end of element.
Returns preserved flag in scalar context.
Returns preserved flag and previous preserved flag in array context.
get
my $preserved_flag = $obj->get;
my ($preserved_flag, $prev_preserved_flag) = $obj->get;
Get preserved flag.
Returns preserved flag in scalar context.
Returns preserved flag and previous preserved flag in array context.
reset
$obj->reset;
Resets.
Returns undef.
save_previous
$obj->save_previous;
Save previous stay.
Returns undef.
ERRORS
new():
From Class::Utils::set_params():
Unknown parameter '%s'.
EXAMPLE
use strict;
use warnings;
use Tags::Utils::Preserve;
# Begin element helper.
sub begin_helper {
my ($pr, $element) = @_;
print "ELEMENT: $element ";
my ($pre, $pre_pre) = $pr->begin($element);
print "PRESERVED: $pre PREVIOUS PRESERVED: $pre_pre\n";
}
# End element helper.
sub end_helper {
my ($pr, $element) = @_;
print "ENDELEMENT: $element ";
my ($pre, $pre_pre) = $pr->end($element);
print "PRESERVED: $pre PREVIOUS PRESERVED: $pre_pre\n";
}
# Object.
my $pr = Tags::Utils::Preserve->new(
'preserved' => ['element']
);
# Process.
begin_helper($pr, 'foo');
begin_helper($pr, 'element');
begin_helper($pr, 'foo');
end_helper($pr, 'foo');
end_helper($pr, 'element');
end_helper($pr, 'foo');
# Output:
# ELEMENT: foo PRESERVED: 0 PREVIOUS PRESERVED: 0
# ELEMENT: element PRESERVED: 1 PREVIOUS PRESERVED: 0
# ELEMENT: foo PRESERVED: 1 PREVIOUS PRESERVED: 1
# ENDELEMENT: foo PRESERVED: 1 PREVIOUS PRESERVED: 1
# ENDELEMENT: element PRESERVED: 0 PREVIOUS PRESERVED: 1
# ENDELEMENT: foo PRESERVED: 0 PREVIOUS PRESERVED: 0
DEPENDENCIES
Class::Utils, List::Util, Readonly.
SEE ALSO
- Task::Tags
-
Install the Tags modules.
REPOSITORY
https://github.com/michal-josef-spacek/Tags
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2005-2024 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.16