I've just tried to avoid that something else as I kept cutting out parts that weren't working, especially with caller, and moved as much of the html stuff out of it as I could.
I went all the way to hard-coding the paths. There's only two for right now.
# crossword params
my %vars = (
cw => path( $path2, 'crosswords' ),
изображение => path( $path2, 'crosswords', 'изображение', "1.атаман.jpg" ),
подписи => path( $path2, 'crosswords', 'подписи', "1.кгосс.txt" ),
);
if ( $vars{изображение}->is_file ) {
say "We have a path to the image";
}
my $rvars = \%vars;
my $ref_html_values = init_values( $title, $path2, $abs );
my %html_vars = %$ref_html_values;
# append returned hash from init
@vars{ keys %html_vars } = values %html_vars;
If the following is init_values(), do I combine the hashes in a robust way?
sub init_values { use strict; use warnings; use 5.011; use Path::Tiny; use utf8; use Data::Dumper; # initializations that must precede main data structure my $images = "images"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; my ($title, $path2, $abs) = (@_); # page params my %vars2 = ( title => $title, headline => undef, place => 'Vancouver', base_url => 'http://www.merrillpjensen.com', css_file => "${title}1.css", header => path( $path2, "hc_input2.txt" ), footer => path( $path2, "footer_center3.txt" ), body => path( $path2, "rebus5.tmpl" ), print_script => "1", code_tmpl => path( $path2, "code2.tmpl" ), oitop => path( $path2, "oitop.txt" ), oibottom => path( $path2, "oibottom.txt" ), to_images => path( $path2, $images ), eng_captions => path( $path2, $captions ), rus_captions => path( $path2, $ruscaptions ), translations => path( $path2, 'translations' ), bottom => path( $path2, "bottom1.txt" ), book => 'Crosswords: ', chapter => 'Кроссво&# +1088;ды', make_puzzle => 1, print_module => 0, script_file => $abs, module_tmpl => path( $path2, "code3.tmpl" ), server_dir => 'perlmonks', image_dir => 'pmimage', ts => 'template_system', css_path => $path2, ini_path => path('/home/bob/Documents/html_template_data/3.m +4;енности.ini'), ); my $rvars2 = \%vars2; #say "hash returned from init"; #say Dumper $rvars2; return $rvars2; }
I'm able to get the captions inputed, and the output makes sense with a few different views to it:
in make russian xword------
lines are л лесопарк
о и о о е
комар р й
л б трасса
ё к т б
пасс ухо
менеджер
фауна раки
тоска г
шкант м е
атаман
в т т
н ухаб
игроки
к грач
with Dumper------
$VAR1 =
"\x{43b} \x{43b}\x{435}\x{441}\x{43e}\x{43f}\x{430}\x{440}\x{43a}
",
"\x{43e} \x{438} \x{43e} \x{43e} \x{435}
",
"\x{43a}\x{43e}\x{43c}\x{430}\x{440} \x{440} \x{439}
",
"\x{43b} \x{431} \x{442}\x{440}\x{430}\x{441}\x{441}\x{430}
",
"\x{451} \x{43a} \x{442} \x{431}
",
"\x{43f}\x{430}\x{441}\x{441} \x{443}\x{445}\x{43e}
",
" \x{43c}\x{435}\x{43d}\x{435}\x{434}\x{436}\x{435}\x{440}
",
"\x{444}\x{430}\x{443}\x{43d}\x{430} \x{440}\x{430}\x{43a}\x{438}
",
" \x{442}\x{43e}\x{441}\x{43a}\x{430} \x{433}
",
"\x{448}\x{43a}\x{430}\x{43d}\x{442} \x{43c} \x{435}
",
" \x{430}\x{442}\x{430}\x{43c}\x{430}\x{43d}
",
" \x{432} \x{442} \x{442}
",
" \x{43d} \x{443}\x{445}\x{430}\x{431}
",
" \x{438}\x{433}\x{440}\x{43e}\x{43a}\x{438}
",
" \x{43a} \x{433}\x{440}\x{430}\x{447}
",
'
'
;
with Dump------
"\x{43B} \x{43B}\x{435}\x{441}\x{43E}\x{43F}\x{430}\x{440}\x{43A}\n",
"\x{43E} \x{438} \x{43E} \x{43E} \x{435} \n",
"\x{43A}\x{43E}\x{43C}\x{430}\x{440} \x{440} \x{439} \n",
"\x{43B} \x{431} \x{442}\x{440}\x{430}\x{441}\x{441}\x{430}\n",
"\x{451} \x{43A} \x{442} \x{431}\n",
"\x{43F}\x{430}\x{441}\x{441} \x{443}\x{445}\x{43E}\n",
" \x{43C}\x{435}\x{43D}\x{435}\x{434}\x{436}\x{435}\x{440}\n",
"\x{444}\x{430}\x{443}\x{43D}\x{430} \x{440}\x{430}\x{43A}\x{438}\n",
" \x{442}\x{43E}\x{441}\x{43A}\x{430} \x{433}\n",
"\x{448}\x{43A}\x{430}\x{43D}\x{442} \x{43C} \x{435}\n",
" \x{430}\x{442}\x{430}\x{43C}\x{430}\x{43D}\n",
" \x{432} \x{442} \x{442} \n",
" \x{43D} \x{443}\x{445}\x{430}\x{431}\n",
" \x{438}\x{433}\x{440}\x{43E}\x{43A}\x{438}\n",
" \x{43A} \x{433}\x{440}\x{430}\x{447}\n",
"\n",
using slurp method--------
guts are л лесопарк
о и о о е
комар р й
л б трасса
ё к т б
пасс ухо
менеджер
фауна раки
тоска г
шкант м е
атаман
в т т
н ухаб
игроки
к грач
This is with the following sub:
sub make_russian_crossword { use 5.011; use warnings; use POSIX qw(strftime); use Path::Tiny; use Encode; use open OUT => ':encoding(UTF-8)', ':std'; use Data::Dumper; use utf8; my $rvars = shift; my %vars = %$rvars; my $munge = strftime( "p%d-%m-%Y-%H-%M-%S\.txt", localtime ); my $in_path = path( $vars{rus_captions}, $munge )->touchpath; say "in make russian xword------"; ##Let mother know that you created a file, *verb* a reference: $vars{log_file} = $in_path; ## input use Path::Tiny methods my @lines = $vars{подписи} +->lines_utf8; say "lines are @lines"; my $ref_lines = \@lines; vars{data} = $ref_lines; say "with Dumper------"; say Dumper $ref_lines; say "with Dump------"; use Data::Dump; dd $ref_lines; #print_aoa_utf8($ref_lines); say "using slurp method--------"; my $guts = $vars{подписи}- +>slurp_utf8; say "guts are $guts"; my $width = 10; ## trim off white space beyond ten for every line # trim leading or trailing whitespace return $rvars; }
Where I'm at is looking for ways to get these data rectangular. In particular, I want to trim the lines to length ten and trim leading and trailing whitespace.
It seems like something that perl would do elegantly.
In reply to Re^5: help with cyrillic characters in odd places
by Aldebaran
in thread help with cyrillic characters in odd places
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |