-
-
Save ology/537402e7db5089f59e3c7955b21ddc02 to your computer and use it in GitHub Desktop.
Remove DOM element conditionally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Mojo::DOM (); | |
use Mojo::File (); | |
my $xml_file = shift || die "Missing XML file\n"; | |
my $path = Mojo::File->new($xml_file); | |
my $dom = Mojo::DOM->new($path->slurp); | |
$dom->find('g')->each(sub { | |
$_->remove if $_->{id} =~ /^path11[0-9]{3}$/; | |
}); | |
print $dom; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment