#!/usr/bin/env perl use warnings; use strict; use Mojo::DOM; my $filename = 'C:/Users/li/data_collection/posts/165644996453.html'; # slurp the whole file into memory open my $fh, '<', $filename or die $!; my $html = do { local $/; <$fh> }; close $fh; my $dom = Mojo::DOM->new($html); my $text = $dom->find('footer')->last->previous->text; print $text,"\n"; # prints "indeed I am"