This version is better, free of unused libraries and unneeded sources you don't have, and russian to get shredded by the code tags. One can make the code tags with fewer keystrokes, but we need to have our write-up capability close to where it's happening. Path::Tiny is great for figuring out where it is and then being able to create files and directories on the fly.
This version has the tags without intervening newlines, which was at first was a bug I tried to fix until I realized I could just as well call it a feature. As it is the caret of my typing moves all the tags toward the end of file.
Then Enter after the closing tag for each paragraph or code segment to maintain legibility for oneself. The readmores are at the end, because you drape that over particulars so that only the willing will have to use their scroll fingers. What follows is new output and then source:
$ ./2.ping3.pl abs is /home/bob/Documents/meditations/2.ping3.pl path1 is /home/bob/Documents/meditations path2 is /home/bob/Documents/meditations/template_stuff This script will build the above path2. Proceed? (y|n)y return5 is 1 How many i tag pairs would you like?: 0 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?: 0 return1 is monastery tags ...tags redacted... return2 is 1 created file /home/bob/Documents/meditations/template_stuff/translatio +ns/27-11-2018-13-31-56.monk.txt $
Source, with user instructions:
$ cat 2.ping3.pl #!/usr/bin/perl -w use 5.011; use Path::Tiny; use POSIX qw(strftime); # initialization that must precede main data structure # User: enter a subdirectory you would like to create # enter a subdirectory of this^^^ for output my $ts = "template_stuff"; my $output = "translations"; ## turning things to Path::Tiny my $abs = path(__FILE__)->absolute; my $path1 = Path::Tiny->cwd; my $path2 = path( $path1, $ts ); say "abs is $abs"; say "path1 is $path1"; say "path2 is $path2"; print "This script will build the above path2. Proceed? (y|n)"; my $prompt = <STDIN>; chomp $prompt; die unless ( $prompt eq "y" ); my $template_file = "1.monk.tmpl"; my $abs_to_template = path( $path2, $template_file )->touchpath; my $string1 = '<{$symbol}></{$symbol}>'; my $return5 = $abs_to_template->spew_utf8($string1); say "return5 is $return5"; # script params my %vars = ( monk_tags => path( $path2, $template_file ), translations => path( $path2, $output ), book => 'monastery tags ', ); my $rvars = \%vars; 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{$output}, $munge )->touchpath; my $return2 = $save_file->spew_utf8($return1); say "return2 is $return2"; say "created file $save_file"; system("gedit $save_file &"); sub write_monk_tags { use warnings; use 5.011; use Text::Template; 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\"}\n"; # User: change these quoted values for different order or tags 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 = <STDIN>; 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__ $
Now I have to go deal with world of concrete, uggh....
In reply to Re: monk tags
by Aldebaran
in thread monk tags
by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |