#!/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 = ; chomp $prompt; die unless ( $prompt eq "y" ); my $template_file = "1.tags.tmpl"; my $abs_to_template = path( $path2, $template_file )->touchpath; # 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( 1, 'C:\Program Files (x86)\Notepad++\notepad++.exe', $save_file ); sub write_monk_tags { use warnings; use 5.011; use Text::Template 'fill_in_string'; my $rvars = shift; my %vars = %$rvars; my $tag_pair = '<{$symbol}>'; my $return; # User: change these quoted values for different order or tags my @buchstaben = qw/i p c pre readmore b/; for my $i (@buchstaben) { $vars{"symbol"} = $i; print "How many $i tag pairs would you like?: "; my $prompt = ; chomp $prompt; while ( $prompt gt 0 ) { my Q::symbol = $i; my $result = fill_in_string( $tag_pair, PACKAGE => Q ); $return = $return . $result; --$prompt; } } return $return; } __END__