#!/usr/bin/perl
use strict;
use warnings;
use feature 'say';
use Mojo::DOM;
my $html = '
technology of S2S translation, also known as Spoken Language Translation (SLT),
is a new application of AI,
- there
- everyone
';
my $dom = Mojo::DOM->new( $html );
# find each span tag
foreach my $id ( $dom->find('span')->each ){
# if the text contans the string Spoken
if ( index($id->text, 'Spoken') > 0){
# replace the node within the DOM
my $text = $id->text;
$text =~ s/Spoken/Derp!/g;
$id->replace( $text );
}
}
# print the updated DOM
say $dom->content;