Data-Edit-Xml-Lint
view release on metacpan or search on metacpan
lib/Data/Edit/Xml/Lint.pm view on Meta::CPAN
# $v =~ m/--/s and confess "Found -- in value of $_=>$v"; # Confess if -- present in attribute value as this will mess up the xml comments
push @s, "<!--${_}: $v -->"; # Place attribute inside a comment
}
join "\n", @s
}
sub read($) #S Reread a linted xml L<file|/file> and extract the L<attributes|/Attributes> associated with the L<lint|/lint>
{my ($file) = @_; # File containing xml
my $s = readFile($file); # Read xml from file
my %a = $s =~ m/<!--(\w+):\s+(.+?)\s+-->/igs; # Get attributes
my @a = split m/\n/, $s; # Split into lines
my $l = {}; # Reconstructed labels
for(@a) # Each source line
{if (/<!--labels:\s+(.+?)\s+-->/gs) # Labels line
{my ($w) = my @w = split /\s+/, $1; # Id, labels
$l->{$_} = $w for @w; # Associate each id and label with the id
}
}
my $d = {}; # Id definitions
( run in 1.692 second using v1.01-cache-2.11-cpan-71847e10f99 )