#!/usr/bin/perl -w use v5.030; 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 = "perlmonks"; my $output = "writeups"; ## 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" ); ## special do-hickeys I want at the end my @list = ( '[id://1177642]', '[mod://Astro::Coord::ECI::Sun]', '[|]', '[|]', '[|]','<', '>', '[', ']' ,''); @list = map { "$_\n" } @list; say "list is @list"; my $return1 = write_monk_tags(); 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( $path2, $output, $munge )->touchpath; my $return2 = $save_file->spew($return1); say "return2 is $return2"; my $return3 = $save_file->append(@list); say "return3 is $return3"; say "created file $save_file"; system( "gedit $save_file &"); sub write_monk_tags { my $tag_pair = ''; my $return = ''; # User: change these quoted values for different order or tags my @buchstaben = qw/i p c pre readmore b/; for my $letter (@buchstaben) { print "How many $letter tag pairs would you like?: "; my $prompt = ; chomp $prompt; while ( $prompt gt 0 ) { my $new_string = $tag_pair; $new_string =~ s/x/${letter}/g; say "new string is $new_string"; $return = $return . $new_string . "\n"; --$prompt; } } return $return; } __END__