Vancouver, Mon Jul 9 23:20:01 2018

Медитация на perlем

some image

My name is Boris, recovering alcoholic, and I am excited to be able to tell my story in a language that I have studied since college. I became enamored with russian literature, culture and wisdom, even as my western religion seemed hokey and fictonalized. The eastern mysticism I saw in russian films appealed to me. In college, I rejected Mormonism in favor of a scientific outlook.

After having left Brigham Young in favor of an eastern state university, I began to drink heavily, and by the time I graduated had many symptoms of an alcoholic, including being admitted to the hospital. Yet the thought never occured to me that the medical professionals who were telling me that I had a case of alcoholism were correct. Mormons aren't alcoholics!

It didn't dawn on me that I was a lapsed Mormon, and I thought that my real problems were of a different nature. Then I believed that my family and my friends had turned on me, and I became a jerk to compensate.

Drinking was a problem with work I got. I lost many jobs to not being up in the morning at the right time. I found others and the cycle repeated. I would meet women at bars and have relationships characterized by the chaos of highs and lows, always so dramatic.

Enough was enough on 7/1/2014. I moved to Oregon to sober up. I started treatment at Central City Concern and started learning some interpersonal tools. I learned how to set boundaries with people.

Меня зовут Борис, выздоравливающий алкоголик, и я очень рад, что могу рассказать свою историю на языке, который я изучал после колледжа. Я полюбил русскую литературу, культуру и мудрость, даже когда моя западная религия казалась хоккейной и фикционированной. Восточная мистика, которую я видел в русских фильмах, понравилась мне. В колледже я отверг мормонизм в пользу научного мировоззрения.

Оставив Бригама Янга в пользу восточного государственного университета, я начал сильно пить, и к тому времени, когда я закончил, было много симптомов алкоголизма, в том числе и в больницу. Но мне никогда не приходило в голову, что медицинские работники, которые говорили мне, что я имел дело с алкоголизмом, были верны. Мормоны не алкоголики!

Меня не расслышало, что я был упущенным мормоном, и я думал, что мои настоящие проблемы носят иной характер. Тогда я верил, что моя семья и мои друзья повернулись ко мне, и я стал рывком, чтобы компенсировать это.

Употребление алкоголя было проблемой с работой, которую я получил. Я потерял много рабочих мест, чтобы не вставать утром в нужное время. Я нашел других, и цикл повторялся. Я встречал женщин в барах и имел отношения, характеризующиеся хаосом максимумов и минимумов, всегда такими драматичными.

Достаточно было 7/1/2014. Я переехал в Орегон, чтобы протрезветь. Я начал лечение в Central City Concern и начал изучать некоторые инструменты межличностного общения. Я научился устанавливать границы с людьми.

some image

Most of all, I have learned how to have a right-sized ego. I no longer feel like the "big boss" when my mood is up nor do I feel purposeless when my mood is down. I feel what I feel without having to try to regulate it with alcohol. This requires radical acceptance of the way things are. I cannot change other people, places and things; I can only change me and what happens under my roof or behind the wheel of my car.

I have found everything about the 9th step promises to be true. Indeed, I think of them as a minimum. I feel lucky every day I wake up a free man, free from the chains of alcoholism. Instead, I have to maintain a spiritual program rooted in meditation, good works, and kindness.

Прежде всего, я узнал, как иметь правильное эго. Я больше не чувствую себя «большим боссом», когда мое настроение поднимается, и я не чувствую себя бесцельно, когда мое настроение опущено. Я чувствую, что чувствую, не пытаясь отрегулировать его алкоголем. Это требует радикального принятия того, как это происходит. Я не могу изменить других людей, места и вещи; Я могу только изменить меня и то, что происходит под моей крышей или за рулем моей машины.

Я нашел все о девятом шаге, обещающем быть правдой. В самом деле, я думаю о них как минимум. Я чувствую себя счастливым каждый день, когда я пробуждаю свободного человека, свободного от цепей алкоголизма. Вместо этого я должен поддерживать духовную программу, основанную на медитации, добрых делах и доброте.

Valid CSS!
Script that produced this: #!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use html4; use nibley1; use utils1; use Net::SFTP::Foreign; use File::Spec; use Path::Tiny; use utf8; use open qw/:std :utf8/; # initializations that must precede main data structure my $fspecfile = File::Spec->rel2abs(__FILE__); my $ts = "template_stuff"; my $images = "aimages"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; ## turning things to Path::Tiny my $path1 = Path::Tiny->cwd; say "path1 is $path1"; my $title =$path1->basename; say "base is $title"; # page params my %vars = ( title => $title, headline => undef, place => 'Vancouver', css_file => "${title}1.css", header => path($path1, $ts,"hc_input2.txt"), footer => path($path1,$ts,"footer_center3.txt"), body => path($path1,$ts,"rebus5.tmpl"), print_script => "1", code_tmpl=> path($path1,$ts,"code2.tmpl"), oitop=> path($path1,"$ts","oitop.txt"), oibottom=> path($path1,$ts,"oibottom.txt"), to_images => path($path1,$ts,$images), eng_captions => path($path1,$ts,$captions), rus_captions => path($path1,$ts,$ruscaptions), bottom => path($path1,$ts,"bottom1.txt"), book => 'Медитация на perlем', chapter => '', print_module => 1, script_file => $fspecfile, module_tmpl=> path($path1, "$ts" ,"code3.tmpl"), server_dir => 'perlmonks', image_dir => 'pmimage', ); #create html page my $rvars = \%vars; #print_hash($rvars); my $sftp = get_ftp_object(); say "object created, back in main"; my $html_file = get_html_filename($sftp, $rvars); my $fh = create_html_file ($html_file); my $remote_dir = $html_file; $remote_dir =~ s/\.html$//; say "remote_dir is $remote_dir"; $vars{remote_dir}= $remote_dir; # create header my $rhdr = write_header($rvars); print $fh $$rhdr; my $refc = get_content($rvars); my @AoA = @$refc; #print_aoa($refc); my $body = write_body($rvars, $refc); print $fh $$body; my $rftr = write_footer($rvars); print $fh $$rftr; if ($vars{"print_script"}) { my $script = write_script($rvars); print $fh $$script; } if ($vars{"print_module"}) { my $module = write_module($rvars); print $fh $$module; } my $rhbt = write_bottom($rvars); print $fh $$rhbt; close $fh; #load html file to server my $server_dir = $vars{"server_dir"}; $sftp->mkdir( "/$server_dir" ) or warn "mkdir1 failed $!\n"; $sftp->setcwd( "/$server_dir" ) or warn "setcwd1 failed $!\n"; $sftp->put($html_file) or die "html put failed $!\n"; #load css file to server $sftp->setcwd("/css") or warn "setcwd2 failed $@\n"; my $path3 = path($path1, $ts, $vars{"css_file"}); say "path3 is $path3"; my $remote_css = $vars{"css_file"}; $sftp->put("$path3", $remote_css) or warn "css put failed $@\n"; # upload images my $image_dir = $vars{"image_dir"}; $sftp->mkdir( "/$image_dir" ) or warn "mkdir2 failed $!\n"; $sftp->setcwd( "/$image_dir" ) or warn "setcwd2 failed $!\n"; $sftp->mkdir( "$remote_dir" ) or warn "mkdir3 failed $!\n"; $sftp->setcwd( "$remote_dir" ) or warn "setcwd3 failed $!\n"; print $sftp->cwd(),"\n"; for my $i ( 0 .. $#AoA ) { my $a = path($path1,$ts,$images,$AoA[$i][0]); say "a is $a"; my $b = $a->basename; say "b is $b"; $sftp->put($a, $b) or warn "AoA put failed $@\n"; } undef $sftp; say "new file is $html_file"; __END__

Module used for this call: package html4; require Exporter; use config2; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( get_content write_body get_ftp_object get_html_filename create_html_file write_script write_bottom write_header write_footer write_module ); sub get_content{ use 5.010; my $rvars = shift; my %vars = %$rvars; my $refimg = get_images($rvars); my $refcaps = get_utf8_text($rvars, $vars{"eng_captions"}); my $refruscaps = get_utf8_text($rvars, $vars{"rus_captions"}); my $aoa = [ $refimg, $refcaps, $refruscaps ]; my $b = invert_aoa($aoa); return ($b); } sub get_images { use strict; use 5.010; my $rvars = shift; my %vars = %$rvars; my @filetypes = qw/jpg gif png jpeg GIF/; my $pattern = join '|', map "($_)", @filetypes; my @matching2; opendir my $hh, $vars{to_images} or warn "warn $!\n"; while (defined ($_ = readdir($hh))){ if ($_ =~ /($pattern)$/i) { push(@matching2, $_); } } #important to sort @matching2 = sort @matching2; return \@matching2; } sub get_utf8_text { use 5.010; use HTML::FromText; use Path::Tiny; use utf8; use open qw/:std :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, urls => 1, email => 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; } sub write_body{ use strict; use warnings; use 5.010; use Text::Template; use Encode; my $rvars = shift; my $reftoAoA = shift; my %vars = %$rvars; my @AoA = @$reftoAoA; my $body = $vars{"body"}; my $template = Text::Template->new( ENCODING => 'utf8', SOURCE => $body) or die "Couldn't construct template: $!"; my $return; for my $i ( 0 .. $#AoA ){ $vars{"file"} = $AoA[$i][0]; $vars{"english"} = $AoA[$i][1]; my $ustring = $AoA[$i][2]; #$ustring = decode_utf8( $ustring ); $vars{"russian"} = $ustring; my $result = $template->fill_in(HASH => \%vars); $return = $return.$result; } return \$return; } sub write_bottom { use strict; use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"bottom"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub get_html_filename{ use Net::SFTP::Foreign; use File::Basename; use Cwd; use 5.01; my ($sftp, $rvars) = (@_); my %vars = %$rvars; # get working directory my $dir = getcwd(); my $word = basename($dir); say "word is $word"; # get files from /pages my $dir2 = $vars{"server_dir"}; say "dir2 is $dir2"; my $ls = $sftp->ls("/$dir2", wanted => qr/$word/) or warn "unable to retrieve ".$sftp->error; print "$_->{filename}\n" for (@$ls); my @remote_files = map { $_->{filename} } @$ls; say "files are @remote_files"; my $rref = \@remote_files; my $filetype = "html"; my $old_num = highest_number($rref, $filetype, $word); print "old num is $old_num\n"; my $new_num = $old_num + 1; my $html_file = $word.$new_num.'.'.$filetype; return $html_file; } sub get_ftp_object{ use strict; use Net::SFTP::Foreign; use 5.01; my $sub_hash = "my_sftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; my $password = $config{$sub_hash}->{'password'}; my $port = 22; #dial up the server say "values are $domain $username $password"; my $sftp = Net::SFTP::Foreign->new( $domain, user => $username, port => $port, password => $password) or die "Can't connect: $!\n"; return $sftp; } sub create_html_file { my $html_file = shift; open( my $fh, ">>:encoding(UTF-8)", $html_file ) or die("Can't open $html_file for writing: $!"); return $fh; } sub write_header { use Text::Template; my $rvars = shift; my %vars = %$rvars; # get time my $now_string = localtime; $vars{"date"} = $now_string; my $headline = join(' ',$vars{"book"},$vars{"chapter"}); $vars{"headline"} = $headline; my $header = $vars{"header"}; my $template2 = Text::Template->new(SOURCE => $header) or die "Couldn't construct template: $!"; my $result2 = $template2->fill_in(HASH => \%vars); return \$result2; } sub write_footer { use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"footer"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub write_script { use Text::Template; use 5.010; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"code_tmpl"}; say "tmpl is $tmpl"; my $file = $vars{"script_file"}; my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('script', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } sub write_module { use 5.010; use File::Spec; use Text::Template; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"module_tmpl"}; say "tmpl is $tmpl"; my $file = File::Spec->rel2abs(__FILE__); my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('module', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } 1;

2.med

Vancouver, Mon Jul 9 23:20:44 2018

Медитация на perlем

some image

My name is Boris, recovering alcoholic, and I am excited to be able to tell my story in a language that I have studied since college. I became enamored with russian literature, culture and wisdom, even as my western religion seemed hokey and fictonalized. The eastern mysticism I saw in russian films appealed to me. In college, I rejected Mormonism in favor of a scientific outlook.

After having left Brigham Young in favor of an eastern state university, I began to drink heavily, and by the time I graduated had many symptoms of an alcoholic, including being admitted to the hospital. Yet the thought never occured to me that the medical professionals who were telling me that I had a case of alcoholism were correct. Mormons aren't alcoholics!

It didn't dawn on me that I was a lapsed Mormon, and I thought that my real problems were of a different nature. Then I believed that my family and my friends had turned on me, and I became a jerk to compensate.

Drinking was a problem with work I got. I lost many jobs to not being up in the morning at the right time. I found others and the cycle repeated. I would meet women at bars and have relationships characterized by the chaos of highs and lows, always so dramatic.

Enough was enough on 7/1/2014. I moved to Oregon to sober up. I started treatment at Central City Concern and started learning some interpersonal tools. I learned how to set boundaries with people.

Меня зовут Борис, выздоравливающий алкоголик, и я очень рад, что могу рассказать свою историю на языке, который я изучал после колледжа. Я полюбил русскую литературу, культуру и мудрость, даже когда моя западная религия казалась хоккейной и фикционированной. Восточная мистика, которую я видел в русских фильмах, понравилась мне. В колледже я отверг мормонизм в пользу научного мировоззрения.

Оставив Бригама Янга в пользу восточного государственного университета, я начал сильно пить, и к тому времени, когда я закончил, было много симптомов алкоголизма, в том числе и в больницу. Но мне никогда не приходило в голову, что медицинские работники, которые говорили мне, что я имел дело с алкоголизмом, были верны. Мормоны не алкоголики!

Меня не расслышало, что я был упущенным мормоном, и я думал, что мои настоящие проблемы носят иной характер. Тогда я верил, что моя семья и мои друзья повернулись ко мне, и я стал рывком, чтобы компенсировать это.

Употребление алкоголя было проблемой с работой, которую я получил. Я потерял много рабочих мест, чтобы не вставать утром в нужное время. Я нашел других, и цикл повторялся. Я встречал женщин в барах и имел отношения, характеризующиеся хаосом максимумов и минимумов, всегда такими драматичными.

Достаточно было 7/1/2014. Я переехал в Орегон, чтобы протрезветь. Я начал лечение в Central City Concern и начал изучать некоторые инструменты межличностного общения. Я научился устанавливать границы с людьми.

some image

Most of all, I have learned how to have a right-sized ego. I no longer feel like the "big boss" when my mood is up nor do I feel purposeless when my mood is down. I feel what I feel without having to try to regulate it with alcohol. This requires radical acceptance of the way things are. I cannot change other people, places and things; I can only change me and what happens under my roof or behind the wheel of my car.

I have found everything about the 9th step promises to be true. Indeed, I think of them as a minimum. I feel lucky every day I wake up a free man, free from the chains of alcoholism. Instead, I have to maintain a spiritual program rooted in meditation, good works, and kindness.

Прежде всего, я узнал, как иметь правильное эго. Я больше не чувствую себя «большим боссом», когда мое настроение поднимается, и я не чувствую себя бесцельно, когда мое настроение опущено. Я чувствую, что чувствую, не пытаясь отрегулировать его алкоголем. Это требует радикального принятия того, как это происходит. Я не могу изменить других людей, места и вещи; Я могу только изменить меня и то, что происходит под моей крышей или за рулем моей машины.

Я нашел все о девятом шаге, обещающем быть правдой. В самом деле, я думаю о них как минимум. Я чувствую себя счастливым каждый день, когда я пробуждаю свободного человека, свободного от цепей алкоголизма. Вместо этого я должен поддерживать духовную программу, основанную на медитации, добрых делах и доброте.

Valid CSS!
Script that produced this: #!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use html4; use nibley1; use utils1; use Net::SFTP::Foreign; use File::Spec; use Path::Tiny; use utf8; use open qw/:std :utf8/; # initializations that must precede main data structure my $fspecfile = File::Spec->rel2abs(__FILE__); my $ts = "template_stuff"; my $images = "aimages"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; ## turning things to Path::Tiny my $path1 = Path::Tiny->cwd; say "path1 is $path1"; my $title =$path1->basename; say "base is $title"; # page params my %vars = ( title => $title, headline => undef, place => 'Vancouver', css_file => "${title}1.css", header => path($path1, $ts,"hc_input2.txt"), footer => path($path1,$ts,"footer_center3.txt"), body => path($path1,$ts,"rebus5.tmpl"), print_script => "1", code_tmpl=> path($path1,$ts,"code2.tmpl"), oitop=> path($path1,"$ts","oitop.txt"), oibottom=> path($path1,$ts,"oibottom.txt"), to_images => path($path1,$ts,$images), eng_captions => path($path1,$ts,$captions), rus_captions => path($path1,$ts,$ruscaptions), bottom => path($path1,$ts,"bottom1.txt"), book => 'Медитация на perlем', chapter => '', print_module => 1, script_file => $fspecfile, module_tmpl=> path($path1, "$ts" ,"code3.tmpl"), server_dir => 'perlmonks', image_dir => 'pmimage', ); #create html page my $rvars = \%vars; #print_hash($rvars); my $sftp = get_ftp_object(); say "object created, back in main"; my $html_file = get_html_filename($sftp, $rvars); my $fh = create_html_file ($html_file); my $remote_dir = $html_file; $remote_dir =~ s/\.html$//; say "remote_dir is $remote_dir"; $vars{remote_dir}= $remote_dir; # create header my $rhdr = write_header($rvars); print $fh $$rhdr; my $refc = get_content($rvars); my @AoA = @$refc; #print_aoa($refc); my $body = write_body($rvars, $refc); print $fh $$body; my $rftr = write_footer($rvars); print $fh $$rftr; if ($vars{"print_script"}) { my $script = write_script($rvars); print $fh $$script; } if ($vars{"print_module"}) { my $module = write_module($rvars); print $fh $$module; } my $rhbt = write_bottom($rvars); print $fh $$rhbt; close $fh; #load html file to server my $server_dir = $vars{"server_dir"}; $sftp->mkdir( "/$server_dir" ) or warn "mkdir1 failed $!\n"; $sftp->setcwd( "/$server_dir" ) or warn "setcwd1 failed $!\n"; $sftp->put($html_file) or die "html put failed $!\n"; #load css file to server $sftp->setcwd("/css") or warn "setcwd2 failed $@\n"; my $path3 = path($path1, $ts, $vars{"css_file"}); say "path3 is $path3"; my $remote_css = $vars{"css_file"}; $sftp->put("$path3", $remote_css) or warn "css put failed $@\n"; # upload images my $image_dir = $vars{"image_dir"}; $sftp->mkdir( "/$image_dir" ) or warn "mkdir2 failed $!\n"; $sftp->setcwd( "/$image_dir" ) or warn "setcwd2 failed $!\n"; $sftp->mkdir( "$remote_dir" ) or warn "mkdir3 failed $!\n"; $sftp->setcwd( "$remote_dir" ) or warn "setcwd3 failed $!\n"; print $sftp->cwd(),"\n"; for my $i ( 0 .. $#AoA ) { my $a = path($path1,$ts,$images,$AoA[$i][0]); say "a is $a"; my $b = $a->basename; say "b is $b"; $sftp->put($a, $b) or warn "AoA put failed $@\n"; } undef $sftp; say "new file is $html_file"; __END__

Module used for this call: package html4; require Exporter; use config2; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( get_content write_body get_ftp_object get_html_filename create_html_file write_script write_bottom write_header write_footer write_module ); sub get_content{ use 5.010; my $rvars = shift; my %vars = %$rvars; my $refimg = get_images($rvars); my $refcaps = get_utf8_text($rvars, $vars{"eng_captions"}); my $refruscaps = get_utf8_text($rvars, $vars{"rus_captions"}); my $aoa = [ $refimg, $refcaps, $refruscaps ]; my $b = invert_aoa($aoa); return ($b); } sub get_images { use strict; use 5.010; my $rvars = shift; my %vars = %$rvars; my @filetypes = qw/jpg gif png jpeg GIF/; my $pattern = join '|', map "($_)", @filetypes; my @matching2; opendir my $hh, $vars{to_images} or warn "warn $!\n"; while (defined ($_ = readdir($hh))){ if ($_ =~ /($pattern)$/i) { push(@matching2, $_); } } #important to sort @matching2 = sort @matching2; return \@matching2; } sub get_utf8_text { use 5.010; use HTML::FromText; use Path::Tiny; use utf8; use open qw/:std :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, urls => 1, email => 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; } sub write_body{ use strict; use warnings; use 5.010; use Text::Template; use Encode; my $rvars = shift; my $reftoAoA = shift; my %vars = %$rvars; my @AoA = @$reftoAoA; my $body = $vars{"body"}; my $template = Text::Template->new( ENCODING => 'utf8', SOURCE => $body) or die "Couldn't construct template: $!"; my $return; for my $i ( 0 .. $#AoA ){ $vars{"file"} = $AoA[$i][0]; $vars{"english"} = $AoA[$i][1]; my $ustring = $AoA[$i][2]; #$ustring = decode_utf8( $ustring ); $vars{"russian"} = $ustring; my $result = $template->fill_in(HASH => \%vars); $return = $return.$result; } return \$return; } sub write_bottom { use strict; use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"bottom"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub get_html_filename{ use Net::SFTP::Foreign; use File::Basename; use Cwd; use 5.01; my ($sftp, $rvars) = (@_); my %vars = %$rvars; # get working directory my $dir = getcwd(); my $word = basename($dir); say "word is $word"; # get files from /pages my $dir2 = $vars{"server_dir"}; say "dir2 is $dir2"; my $ls = $sftp->ls("/$dir2", wanted => qr/$word/) or warn "unable to retrieve ".$sftp->error; print "$_->{filename}\n" for (@$ls); my @remote_files = map { $_->{filename} } @$ls; say "files are @remote_files"; my $rref = \@remote_files; my $filetype = "html"; my $old_num = highest_number($rref, $filetype, $word); print "old num is $old_num\n"; my $new_num = $old_num + 1; my $html_file = $word.$new_num.'.'.$filetype; return $html_file; } sub get_ftp_object{ use strict; use Net::SFTP::Foreign; use 5.01; my $sub_hash = "my_sftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; my $password = $config{$sub_hash}->{'password'}; my $port = 22; #dial up the server say "values are $domain $username $password"; my $sftp = Net::SFTP::Foreign->new( $domain, user => $username, port => $port, password => $password) or die "Can't connect: $!\n"; return $sftp; } sub create_html_file { my $html_file = shift; open( my $fh, ">>:encoding(UTF-8)", $html_file ) or die("Can't open $html_file for writing: $!"); return $fh; } sub write_header { use Text::Template; my $rvars = shift; my %vars = %$rvars; # get time my $now_string = localtime; $vars{"date"} = $now_string; my $headline = join(' ',$vars{"book"},$vars{"chapter"}); $vars{"headline"} = $headline; my $header = $vars{"header"}; my $template2 = Text::Template->new(SOURCE => $header) or die "Couldn't construct template: $!"; my $result2 = $template2->fill_in(HASH => \%vars); return \$result2; } sub write_footer { use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"footer"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub write_script { use Text::Template; use 5.010; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"code_tmpl"}; say "tmpl is $tmpl"; my $file = $vars{"script_file"}; my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('script', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } sub write_module { use 5.010; use File::Spec; use Text::Template; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"module_tmpl"}; say "tmpl is $tmpl"; my $file = File::Spec->rel2abs(__FILE__); my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('module', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } 1;

2.med

Vancouver, Mon Jul 9 23:20:57 2018

Медитация на perlем

some image

My name is Boris, recovering alcoholic, and I am excited to be able to tell my story in a language that I have studied since college. I became enamored with russian literature, culture and wisdom, even as my western religion seemed hokey and fictonalized. The eastern mysticism I saw in russian films appealed to me. In college, I rejected Mormonism in favor of a scientific outlook.

After having left Brigham Young in favor of an eastern state university, I began to drink heavily, and by the time I graduated had many symptoms of an alcoholic, including being admitted to the hospital. Yet the thought never occured to me that the medical professionals who were telling me that I had a case of alcoholism were correct. Mormons aren't alcoholics!

It didn't dawn on me that I was a lapsed Mormon, and I thought that my real problems were of a different nature. Then I believed that my family and my friends had turned on me, and I became a jerk to compensate.

Drinking was a problem with work I got. I lost many jobs to not being up in the morning at the right time. I found others and the cycle repeated. I would meet women at bars and have relationships characterized by the chaos of highs and lows, always so dramatic.

Enough was enough on 7/1/2014. I moved to Oregon to sober up. I started treatment at Central City Concern and started learning some interpersonal tools. I learned how to set boundaries with people.

Меня зовут Борис, выздоравливающий алкоголик, и я очень рад, что могу рассказать свою историю на языке, который я изучал после колледжа. Я полюбил русскую литературу, культуру и мудрость, даже когда моя западная религия казалась хоккейной и фикционированной. Восточная мистика, которую я видел в русских фильмах, понравилась мне. В колледже я отверг мормонизм в пользу научного мировоззрения.

Оставив Бригама Янга в пользу восточного государственного университета, я начал сильно пить, и к тому времени, когда я закончил, было много симптомов алкоголизма, в том числе и в больницу. Но мне никогда не приходило в голову, что медицинские работники, которые говорили мне, что я имел дело с алкоголизмом, были верны. Мормоны не алкоголики!

Меня не расслышало, что я был упущенным мормоном, и я думал, что мои настоящие проблемы носят иной характер. Тогда я верил, что моя семья и мои друзья повернулись ко мне, и я стал рывком, чтобы компенсировать это.

Употребление алкоголя было проблемой с работой, которую я получил. Я потерял много рабочих мест, чтобы не вставать утром в нужное время. Я нашел других, и цикл повторялся. Я встречал женщин в барах и имел отношения, характеризующиеся хаосом максимумов и минимумов, всегда такими драматичными.

Достаточно было 7/1/2014. Я переехал в Орегон, чтобы протрезветь. Я начал лечение в Central City Concern и начал изучать некоторые инструменты межличностного общения. Я научился устанавливать границы с людьми.

some image

Most of all, I have learned how to have a right-sized ego. I no longer feel like the "big boss" when my mood is up nor do I feel purposeless when my mood is down. I feel what I feel without having to try to regulate it with alcohol. This requires radical acceptance of the way things are. I cannot change other people, places and things; I can only change me and what happens under my roof or behind the wheel of my car.

I have found everything about the 9th step promises to be true. Indeed, I think of them as a minimum. I feel lucky every day I wake up a free man, free from the chains of alcoholism. Instead, I have to maintain a spiritual program rooted in meditation, good works, and kindness.

Прежде всего, я узнал, как иметь правильное эго. Я больше не чувствую себя «большим боссом», когда мое настроение поднимается, и я не чувствую себя бесцельно, когда мое настроение опущено. Я чувствую, что чувствую, не пытаясь отрегулировать его алкоголем. Это требует радикального принятия того, как это происходит. Я не могу изменить других людей, места и вещи; Я могу только изменить меня и то, что происходит под моей крышей или за рулем моей машины.

Я нашел все о девятом шаге, обещающем быть правдой. В самом деле, я думаю о них как минимум. Я чувствую себя счастливым каждый день, когда я пробуждаю свободного человека, свободного от цепей алкоголизма. Вместо этого я должен поддерживать духовную программу, основанную на медитации, добрых делах и доброте.

Valid CSS!
Script that produced this: #!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use html4; use nibley1; use utils1; use Net::SFTP::Foreign; use File::Spec; use Path::Tiny; use utf8; use open qw/:std :utf8/; # initializations that must precede main data structure my $fspecfile = File::Spec->rel2abs(__FILE__); my $ts = "template_stuff"; my $images = "aimages"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; ## turning things to Path::Tiny my $path1 = Path::Tiny->cwd; say "path1 is $path1"; my $title =$path1->basename; say "base is $title"; # page params my %vars = ( title => $title, headline => undef, place => 'Vancouver', css_file => "${title}1.css", header => path($path1, $ts,"hc_input2.txt"), footer => path($path1,$ts,"footer_center3.txt"), body => path($path1,$ts,"rebus5.tmpl"), print_script => "1", code_tmpl=> path($path1,$ts,"code2.tmpl"), oitop=> path($path1,"$ts","oitop.txt"), oibottom=> path($path1,$ts,"oibottom.txt"), to_images => path($path1,$ts,$images), eng_captions => path($path1,$ts,$captions), rus_captions => path($path1,$ts,$ruscaptions), bottom => path($path1,$ts,"bottom1.txt"), book => 'Медитация на perlем', chapter => '', print_module => 1, script_file => $fspecfile, module_tmpl=> path($path1, "$ts" ,"code3.tmpl"), server_dir => 'perlmonks', image_dir => 'pmimage', ); #create html page my $rvars = \%vars; #print_hash($rvars); my $sftp = get_ftp_object(); say "object created, back in main"; my $html_file = get_html_filename($sftp, $rvars); my $fh = create_html_file ($html_file); my $remote_dir = $html_file; $remote_dir =~ s/\.html$//; say "remote_dir is $remote_dir"; $vars{remote_dir}= $remote_dir; # create header my $rhdr = write_header($rvars); print $fh $$rhdr; my $refc = get_content($rvars); my @AoA = @$refc; #print_aoa($refc); my $body = write_body($rvars, $refc); print $fh $$body; my $rftr = write_footer($rvars); print $fh $$rftr; if ($vars{"print_script"}) { my $script = write_script($rvars); print $fh $$script; } if ($vars{"print_module"}) { my $module = write_module($rvars); print $fh $$module; } my $rhbt = write_bottom($rvars); print $fh $$rhbt; close $fh; #load html file to server my $server_dir = $vars{"server_dir"}; $sftp->mkdir( "/$server_dir" ) or warn "mkdir1 failed $!\n"; $sftp->setcwd( "/$server_dir" ) or warn "setcwd1 failed $!\n"; $sftp->put($html_file) or die "html put failed $!\n"; #load css file to server $sftp->setcwd("/css") or warn "setcwd2 failed $@\n"; my $path3 = path($path1, $ts, $vars{"css_file"}); say "path3 is $path3"; my $remote_css = $vars{"css_file"}; $sftp->put("$path3", $remote_css) or warn "css put failed $@\n"; # upload images my $image_dir = $vars{"image_dir"}; $sftp->mkdir( "/$image_dir" ) or warn "mkdir2 failed $!\n"; $sftp->setcwd( "/$image_dir" ) or warn "setcwd2 failed $!\n"; $sftp->mkdir( "$remote_dir" ) or warn "mkdir3 failed $!\n"; $sftp->setcwd( "$remote_dir" ) or warn "setcwd3 failed $!\n"; print $sftp->cwd(),"\n"; for my $i ( 0 .. $#AoA ) { my $a = path($path1,$ts,$images,$AoA[$i][0]); say "a is $a"; my $b = $a->basename; say "b is $b"; $sftp->put($a, $b) or warn "AoA put failed $@\n"; } undef $sftp; say "new file is $html_file"; __END__

Module used for this call: package html4; require Exporter; use config2; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( get_content write_body get_ftp_object get_html_filename create_html_file write_script write_bottom write_header write_footer write_module ); sub get_content{ use 5.010; my $rvars = shift; my %vars = %$rvars; my $refimg = get_images($rvars); my $refcaps = get_utf8_text($rvars, $vars{"eng_captions"}); my $refruscaps = get_utf8_text($rvars, $vars{"rus_captions"}); my $aoa = [ $refimg, $refcaps, $refruscaps ]; my $b = invert_aoa($aoa); return ($b); } sub get_images { use strict; use 5.010; my $rvars = shift; my %vars = %$rvars; my @filetypes = qw/jpg gif png jpeg GIF/; my $pattern = join '|', map "($_)", @filetypes; my @matching2; opendir my $hh, $vars{to_images} or warn "warn $!\n"; while (defined ($_ = readdir($hh))){ if ($_ =~ /($pattern)$/i) { push(@matching2, $_); } } #important to sort @matching2 = sort @matching2; return \@matching2; } sub get_utf8_text { use 5.010; use HTML::FromText; use Path::Tiny; use utf8; use open qw/:std :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, urls => 1, email => 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; } sub write_body{ use strict; use warnings; use 5.010; use Text::Template; use Encode; my $rvars = shift; my $reftoAoA = shift; my %vars = %$rvars; my @AoA = @$reftoAoA; my $body = $vars{"body"}; my $template = Text::Template->new( ENCODING => 'utf8', SOURCE => $body) or die "Couldn't construct template: $!"; my $return; for my $i ( 0 .. $#AoA ){ $vars{"file"} = $AoA[$i][0]; $vars{"english"} = $AoA[$i][1]; my $ustring = $AoA[$i][2]; #$ustring = decode_utf8( $ustring ); $vars{"russian"} = $ustring; my $result = $template->fill_in(HASH => \%vars); $return = $return.$result; } return \$return; } sub write_bottom { use strict; use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"bottom"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub get_html_filename{ use Net::SFTP::Foreign; use File::Basename; use Cwd; use 5.01; my ($sftp, $rvars) = (@_); my %vars = %$rvars; # get working directory my $dir = getcwd(); my $word = basename($dir); say "word is $word"; # get files from /pages my $dir2 = $vars{"server_dir"}; say "dir2 is $dir2"; my $ls = $sftp->ls("/$dir2", wanted => qr/$word/) or warn "unable to retrieve ".$sftp->error; print "$_->{filename}\n" for (@$ls); my @remote_files = map { $_->{filename} } @$ls; say "files are @remote_files"; my $rref = \@remote_files; my $filetype = "html"; my $old_num = highest_number($rref, $filetype, $word); print "old num is $old_num\n"; my $new_num = $old_num + 1; my $html_file = $word.$new_num.'.'.$filetype; return $html_file; } sub get_ftp_object{ use strict; use Net::SFTP::Foreign; use 5.01; my $sub_hash = "my_sftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; my $password = $config{$sub_hash}->{'password'}; my $port = 22; #dial up the server say "values are $domain $username $password"; my $sftp = Net::SFTP::Foreign->new( $domain, user => $username, port => $port, password => $password) or die "Can't connect: $!\n"; return $sftp; } sub create_html_file { my $html_file = shift; open( my $fh, ">>:encoding(UTF-8)", $html_file ) or die("Can't open $html_file for writing: $!"); return $fh; } sub write_header { use Text::Template; my $rvars = shift; my %vars = %$rvars; # get time my $now_string = localtime; $vars{"date"} = $now_string; my $headline = join(' ',$vars{"book"},$vars{"chapter"}); $vars{"headline"} = $headline; my $header = $vars{"header"}; my $template2 = Text::Template->new(SOURCE => $header) or die "Couldn't construct template: $!"; my $result2 = $template2->fill_in(HASH => \%vars); return \$result2; } sub write_footer { use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"footer"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub write_script { use Text::Template; use 5.010; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"code_tmpl"}; say "tmpl is $tmpl"; my $file = $vars{"script_file"}; my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('script', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } sub write_module { use 5.010; use File::Spec; use Text::Template; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"module_tmpl"}; say "tmpl is $tmpl"; my $file = File::Spec->rel2abs(__FILE__); my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('module', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } 1;

2.med

Vancouver, Tue Jul 10 11:47:42 2018

Медитация на perlем

some image

My name is Boris, recovering alcoholic, and I am excited to be able to tell my story in a language that I have studied since college. I became enamored with russian literature, culture and wisdom, even as my western religion seemed hokey and fictonalized. The eastern mysticism I saw in russian films appealed to me. In college, I rejected Mormonism in favor of a scientific outlook.

After having left Brigham Young in favor of an eastern state university, I began to drink heavily, and by the time I graduated had many symptoms of an alcoholic, including being admitted to the hospital. Yet the thought never occured to me that the medical professionals who were telling me that I had a case of alcoholism were correct. Mormons aren't alcoholics!

It didn't dawn on me that I was a lapsed Mormon, and I thought that my real problems were of a different nature. Then I believed that my family and my friends had turned on me, and I became a jerk to compensate.

Drinking was a problem with work I got. I lost many jobs to not being up in the morning at the right time. I found others and the cycle repeated. I would meet women at bars and have relationships characterized by the chaos of highs and lows, always so dramatic.

Enough was enough on 7/1/2014. I moved to Oregon to sober up. I started treatment at Central City Concern and started learning some interpersonal tools. I learned how to set boundaries with people.

Меня зовут Борис, выздоравливающий алкоголик, и я очень рад, что могу рассказать свою историю на языке, который я изучал после колледжа. Я полюбил русскую литературу, культуру и мудрость, даже когда моя западная религия казалась хоккейной и фикционированной. Восточная мистика, которую я видел в русских фильмах, понравилась мне. В колледже я отверг мормонизм в пользу научного мировоззрения.

Оставив Бригама Янга в пользу восточного государственного университета, я начал сильно пить, и к тому времени, когда я закончил, было много симптомов алкоголизма, в том числе и в больницу. Но мне никогда не приходило в голову, что медицинские работники, которые говорили мне, что я имел дело с алкоголизмом, были верны. Мормоны не алкоголики!

Меня не расслышало, что я был упущенным мормоном, и я думал, что мои настоящие проблемы носят иной характер. Тогда я верил, что моя семья и мои друзья повернулись ко мне, и я стал рывком, чтобы компенсировать это.

Употребление алкоголя было проблемой с работой, которую я получил. Я потерял много рабочих мест, чтобы не вставать утром в нужное время. Я нашел других, и цикл повторялся. Я встречал женщин в барах и имел отношения, характеризующиеся хаосом максимумов и минимумов, всегда такими драматичными.

Достаточно было 7/1/2014. Я переехал в Орегон, чтобы протрезветь. Я начал лечение в Central City Concern и начал изучать некоторые инструменты межличностного общения. Я научился устанавливать границы с людьми.

some image

Most of all, I have learned how to have a right-sized ego. I no longer feel like the "big boss" when my mood is up nor do I feel purposeless when my mood is down. I feel what I feel without having to try to regulate it with alcohol. This requires radical acceptance of the way things are. I cannot change other people, places and things; I can only change me and what happens under my roof or behind the wheel of my car.

I have found everything about the 9th step promises to be true. Indeed, I think of them as a minimum. I feel lucky every day I wake up a free man, free from the chains of alcoholism. Instead, I have to maintain a spiritual program rooted in meditation, good works, and kindness.

Прежде всего, я узнал, как иметь правильное эго. Я больше не чувствую себя «большим боссом», когда мое настроение поднимается, и я не чувствую себя бесцельно, когда мое настроение опущено. Я чувствую, что чувствую, не пытаясь отрегулировать его алкоголем. Это требует радикального принятия того, как это происходит. Я не могу изменить других людей, места и вещи; Я могу только изменить меня и то, что происходит под моей крышей или за рулем моей машины.

Я нашел все о девятом шаге, обещающем быть правдой. В самом деле, я думаю о них как минимум. Я чувствую себя счастливым каждый день, когда я пробуждаю свободного человека, свободного от цепей алкоголизма. Вместо этого я должен поддерживать духовную программу, основанную на медитации, добрых делах и доброте.

Valid CSS!
Script that produced this: #!/usr/bin/perl -w use strict; use 5.010; use lib "template_stuff"; use html4; use nibley1; use utils1; use Net::SFTP::Foreign; use File::Spec; use Path::Tiny; use utf8; use open qw/:std :utf8/; # initializations that must precede main data structure my $fspecfile = File::Spec->rel2abs(__FILE__); my $ts = "template_stuff"; my $images = "aimages"; my $captions = "captions"; my $ruscaptions = "ruscaptions"; ## turning things to Path::Tiny my $path1 = Path::Tiny->cwd; say "path1 is $path1"; my $title =$path1->basename; say "base is $title"; # page params my %vars = ( title => $title, headline => undef, place => 'Vancouver', css_file => "${title}1.css", header => path($path1, $ts,"hc_input2.txt"), footer => path($path1,$ts,"footer_center3.txt"), body => path($path1,$ts,"rebus5.tmpl"), print_script => "1", code_tmpl=> path($path1,$ts,"code2.tmpl"), oitop=> path($path1,"$ts","oitop.txt"), oibottom=> path($path1,$ts,"oibottom.txt"), to_images => path($path1,$ts,$images), eng_captions => path($path1,$ts,$captions), rus_captions => path($path1,$ts,$ruscaptions), bottom => path($path1,$ts,"bottom1.txt"), book => 'Медитация на perlем', chapter => '', print_module => 1, script_file => $fspecfile, module_tmpl=> path($path1, "$ts" ,"code3.tmpl"), server_dir => 'perlmonks', image_dir => 'pmimage', ); #create html page my $rvars = \%vars; #print_hash($rvars); my $sftp = get_ftp_object(); say "object created, back in main"; my $html_file = get_html_filename($sftp, $rvars); my $fh = create_html_file ($html_file); my $remote_dir = $html_file; $remote_dir =~ s/\.html$//; say "remote_dir is $remote_dir"; $vars{remote_dir}= $remote_dir; # create header my $rhdr = write_header($rvars); print $fh $$rhdr; my $refc = get_content($rvars); my @AoA = @$refc; #print_aoa($refc); my $body = write_body($rvars, $refc); print $fh $$body; my $rftr = write_footer($rvars); print $fh $$rftr; if ($vars{"print_script"}) { my $script = write_script($rvars); print $fh $$script; } if ($vars{"print_module"}) { my $module = write_module($rvars); print $fh $$module; } my $rhbt = write_bottom($rvars); print $fh $$rhbt; close $fh; #load html file to server my $server_dir = $vars{"server_dir"}; $sftp->mkdir( "/$server_dir" ) or warn "mkdir1 failed $!\n"; $sftp->setcwd( "/$server_dir" ) or warn "setcwd1 failed $!\n"; $sftp->put($html_file) or die "html put failed $!\n"; #load css file to server $sftp->setcwd("/css") or warn "setcwd2 failed $@\n"; my $path3 = path($path1, $ts, $vars{"css_file"}); say "path3 is $path3"; my $remote_css = $vars{"css_file"}; $sftp->put("$path3", $remote_css) or warn "css put failed $@\n"; # upload images my $image_dir = $vars{"image_dir"}; $sftp->mkdir( "/$image_dir" ) or warn "mkdir2 failed $!\n"; $sftp->setcwd( "/$image_dir" ) or warn "setcwd2 failed $!\n"; $sftp->mkdir( "$remote_dir" ) or warn "mkdir3 failed $!\n"; $sftp->setcwd( "$remote_dir" ) or warn "setcwd3 failed $!\n"; print $sftp->cwd(),"\n"; for my $i ( 0 .. $#AoA ) { my $a = path($path1,$ts,$images,$AoA[$i][0]); say "a is $a"; my $b = $a->basename; say "b is $b"; $sftp->put($a, $b) or warn "AoA put failed $@\n"; } undef $sftp; say "new file is $html_file"; __END__

Module used for this call: package html4; require Exporter; use config2; use utils1; our @ISA = qw(Exporter); our @EXPORT = qw( get_content write_body get_ftp_object get_html_filename create_html_file write_script write_bottom write_header write_footer write_module ); sub get_content{ use 5.010; my $rvars = shift; my %vars = %$rvars; my $refimg = get_images($rvars); my $refcaps = get_utf8_text($rvars, $vars{"eng_captions"}); my $refruscaps = get_utf8_text($rvars, $vars{"rus_captions"}); my $aoa = [ $refimg, $refcaps, $refruscaps ]; my $b = invert_aoa($aoa); return ($b); } sub get_images { use strict; use 5.010; my $rvars = shift; my %vars = %$rvars; my @filetypes = qw/jpg gif png jpeg GIF/; my $pattern = join '|', map "($_)", @filetypes; my @matching2; opendir my $hh, $vars{to_images} or warn "warn $!\n"; while (defined ($_ = readdir($hh))){ if ($_ =~ /($pattern)$/i) { push(@matching2, $_); } } #important to sort @matching2 = sort @matching2; return \@matching2; } sub get_utf8_text { use 5.010; use HTML::FromText; use Path::Tiny; use utf8; use open qw/:std :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, urls => 1, email => 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; } sub write_body{ use strict; use warnings; use 5.010; use Text::Template; use Encode; my $rvars = shift; my $reftoAoA = shift; my %vars = %$rvars; my @AoA = @$reftoAoA; my $body = $vars{"body"}; my $template = Text::Template->new( ENCODING => 'utf8', SOURCE => $body) or die "Couldn't construct template: $!"; my $return; for my $i ( 0 .. $#AoA ){ $vars{"file"} = $AoA[$i][0]; $vars{"english"} = $AoA[$i][1]; my $ustring = $AoA[$i][2]; #$ustring = decode_utf8( $ustring ); $vars{"russian"} = $ustring; my $result = $template->fill_in(HASH => \%vars); $return = $return.$result; } return \$return; } sub write_bottom { use strict; use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"bottom"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub get_html_filename{ use Net::SFTP::Foreign; use File::Basename; use Cwd; use 5.01; my ($sftp, $rvars) = (@_); my %vars = %$rvars; # get working directory my $dir = getcwd(); my $word = basename($dir); say "word is $word"; # get files from /pages my $dir2 = $vars{"server_dir"}; say "dir2 is $dir2"; my $ls = $sftp->ls("/$dir2", wanted => qr/$word/) or warn "unable to retrieve ".$sftp->error; print "$_->{filename}\n" for (@$ls); my @remote_files = map { $_->{filename} } @$ls; say "files are @remote_files"; my $rref = \@remote_files; my $filetype = "html"; my $old_num = highest_number($rref, $filetype, $word); print "old num is $old_num\n"; my $new_num = $old_num + 1; my $html_file = $word.$new_num.'.'.$filetype; return $html_file; } sub get_ftp_object{ use strict; use Net::SFTP::Foreign; use 5.01; my $sub_hash = "my_sftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; my $password = $config{$sub_hash}->{'password'}; my $port = 22; #dial up the server say "values are $domain $username $password"; my $sftp = Net::SFTP::Foreign->new( $domain, user => $username, port => $port, password => $password) or die "Can't connect: $!\n"; return $sftp; } sub create_html_file { my $html_file = shift; open( my $fh, ">>:encoding(UTF-8)", $html_file ) or die("Can't open $html_file for writing: $!"); return $fh; } sub write_header { use Text::Template; my $rvars = shift; my %vars = %$rvars; # get time my $now_string = localtime; $vars{"date"} = $now_string; my $headline = join(' ',$vars{"book"},$vars{"chapter"}); $vars{"headline"} = $headline; my $header = $vars{"header"}; my $template2 = Text::Template->new(SOURCE => $header) or die "Couldn't construct template: $!"; my $result2 = $template2->fill_in(HASH => \%vars); return \$result2; } sub write_footer { use Text::Template; my ($rvars) = shift; my %vars = %$rvars; my $footer = $vars{"footer"}; my $template = Text::Template->new(SOURCE => $footer) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH => $rvars); return \$result; } sub write_script { use Text::Template; use 5.010; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"code_tmpl"}; say "tmpl is $tmpl"; my $file = $vars{"script_file"}; my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('script', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } sub write_module { use 5.010; use File::Spec; use Text::Template; use utf8; my ($rvars) = shift; my %vars = %$rvars; my $tmpl = $vars{"module_tmpl"}; say "tmpl is $tmpl"; my $file = File::Spec->rel2abs(__FILE__); my $text = do { open my $fh, '<:raw:encoding(UTF-8)', $file or die "$file: $!"; local $/; <$fh> }; my %data = ('module', $text); my $template = Text::Template->new(SOURCE => $tmpl) or die "Couldn't construct template: $!"; my $result = $template->fill_in(HASH =>\%data); return \$result; } 1;