sub get_utf8_text { use 5.010; use HTML::FromText; use Path::Tiny; use utf8; use open OUT => ':utf8'; ### Passing in #reference to main data structure and directory for captions my ( $rvars, $dir ) = (@_); my %vars = %$rvars; say "dir is $dir"; opendir my $eh, $dir or warn "can't open dir for utf8 captions $!\n"; while ( defined( $_ = readdir($eh) ) ) { next if m/~$/; next if -d; if (m/txt$/) { my $file = path( $dir, $_ ); my $guts = $file->slurp_utf8; my $temp = text2html( $guts, lines => 1, paras => 1, ); # surround by divs my $oitop = $vars{"oitop"}; my $oben = $oitop->slurp_utf8; my $oibottom = $vars{"oibottom"}; my $unten = $oibottom->slurp_utf8; my $text = $oben . $temp . $unten; say "text is $text"; $content{$_} = $text; } } closedir $eh; #important to sort my @return; foreach my $key ( sort keys %content ) { #print $content{$key} . "\n"; push @return, $content{$key}; } return \@return; } ####
л лесопарк
о и о о е
комар р й
л б трасса
ё к т б
пасс ухо
менеджер
фауна раки
тоска г
шкант м е
атаман
в т т
н ухаб
игроки
к грач
##
## # surround by divs my $oitop = $vars{"oitop"}; my $oben = $oitop->slurp_utf8; my $oibottom = $vars{"oibottom"}; my $unten = $oibottom->slurp_utf8; my $text = $oben . $temp . $unten; #### $ cat oi*.txt
$ ##
## .outer { background-color:white; margin-left : auto; margin-right : auto; border-radius : 1em; clear: left; margin-top: .7em; margin-bottom: .7em; max-width:25%; display:block; } .hft-lines { background-color:white; margin-left : auto; margin-right : auto; border-radius : 1em; clear: left; margin-top: .7em; margin-bottom: .7em; max-width:85%; display:block; text-align:center; font-size: 1.5em; }