$ ./2.ping1.pl basename is 2.ping path1 is /home/bob/2.scripts/pages/2.ping abs is /home/bob/2.scripts/pages/2.ping/2.ping1.pl variable is переменная переменная is variable How many i tag pairs would you like?: 2 How many p tag pairs would you like?: 5 How many c tag pairs would you like?: 3 How many readmore tag pairs would you like?: 1 How many b tag pairs would you like?: 1 return1 is monk tags : ... [russian doesn't render in code tags] return2 is 1 #### $ cat 2.ping1.pl #!/usr/bin/perl -w use 5.011; use lib "template_stuff"; use html7; use trans1; use Path::Tiny; use utf8; use Encode; use open OUT => ':encoding(UTF-8)', ':std'; use POSIX qw(strftime); binmode STDOUT, ":utf8"; # initializations that must precede main data structure my $ts = "template_stuff"; my $images = "aimages"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; ## turning things to Path::Tiny # decode paths my $abs = path(__FILE__)->absolute; my $path1 = Path::Tiny->cwd; my $title = $path1->basename; $abs = decode('UTF-8', $abs); $path1 = decode('UTF-8', $path1); $title = decode('UTF-8', $title); say "basename is $title"; say "path1 is $path1"; say "abs is $abs"; my $path2 = path( $path1, $ts ); # page params my %vars = ( monk_tags => path( $path2, "1.monk.tmpl" ), translations => path( $path2, 'translations' ), book => 'monk tags ', chapter => 'монах теги', server_dir => 'perlmonks', image_dir => 'pmimage', ); my $variable = "переменная"; say "variable is $variable"; my $переменная = "variable"; say "переменная is $переменная"; my $rvars = \%vars; #my $return = create_page( $rvars ); my $return1 = write_monk_tags( $rvars ); say "return1 is $return1"; my $munge = strftime( "%d-%m-%Y-%H-%M-%S", localtime ); $munge .= ".monk.txt"; # use Path::Tiny to create and write to a text in relevant directory my $save_file = path($vars{"translations"}, $munge)->touchpath; my $return2 = $save_file->spew_utf8($return1); say "return2 is $return2"; system("gedit $save_file &"); sub write_monk_tags { use warnings; use 5.011; use Text::Template; use Encode; use utf8; binmode STDOUT, ":utf8"; use open OUT => ':encoding(UTF-8)', ':std'; my $rvars = shift; my %vars = %$rvars; my $body = $vars{"monk_tags"}; my $template = Text::Template->new( ENCODING => 'utf8', SOURCE => "$body", ) or die "Couldn't construct template: $!"; my $return = "$vars{\"book\"}: $vars{\"chapter\"}.\n"; my @buchstaben = qw/i p c readmore b/; for my $i (@buchstaben ) { $vars{"symbol"} = $i; print "How many $i tag pairs would you like?: "; my $prompt = ; chomp $prompt; if ($prompt lt 1) { $prompt = 0; } while ($prompt gt 0){ my $result = $template->fill_in( HASH => \%vars ); $return = $return . $result; --$prompt; } } return $return; } __END__ $ #### $ cat 1.monk.tmpl <{$symbol}> $