$ ./1.vater_unser.pl path1 is /home/bob/Documents/meditations input is {$Our_Father}, who art in heaven, Hallowed be thy name. {$Thy_kingdom_come}, Thy will be done, On earth as it is in heaven. Give us this day our daily bread; And forgive us our trespasses, As we also have forgiven our trespasses; And lead us not into temptation, But deliver us from {$evil}. For thine is the {$kingdom} and the power and the glory, for ever. Amen. out_file is /home/bob/Documents/meditations/my_data/26-04-2019-19-01-55/26-04-2019-19-01-55.1.txt out_file is /home/bob/Documents/meditations/my_data/26-04-2019-19-01-55/26-04-2019-19-01-55.2.txt out_file is /home/bob/Documents/meditations/my_data/26-04-2019-19-01-55/26-04-2019-19-01-55.3.txt OUTFILES******************* Group Of Drunks, who art in heaven, Hallowed be thy name. Ta ti ti ta, Thy will be done, On earth as it is in heaven. Give us this day our daily bread; And forgive us our trespasses, As we also have forgiven our trespasses; And lead us not into temptation, But deliver us from being too serious. For thine is the realm and the power and the glory, for ever. Amen. ------------- our mother, who art in heaven, Hallowed be thy name. Ta ti ti ta, Thy will be done, On earth as it is in heaven. Give us this day our daily bread; And forgive us our trespasses, As we also have forgiven our trespasses; And lead us not into temptation, But deliver us from your followers. For thine is the oligarchy and the power and the glory, for ever. Amen. ------------- Group Of Drunks, who art in heaven, Hallowed be thy name. Armageddon can wait, Thy will be done, On earth as it is in heaven. Give us this day our daily bread; And forgive us our trespasses, As we also have forgiven our trespasses; And lead us not into temptation, But deliver us from ego. For thine is the oligarchy and the power and the glory, for ever. Amen. ------------- $ #### #!/usr/bin/perl -w use 5.011; use Path::Tiny; use utf8; use open OUT => ':utf8'; use Data::Dump; use Text::Template; use POSIX qw(strftime); binmode STDOUT, 'utf8'; my $input = <<'(END INPUT)'; {$Our_Father}, who art in heaven, Hallowed be thy name. {$Thy_kingdom_come}, Thy will be done, On earth as it is in heaven. Give us this day our daily bread; And forgive us our trespasses, As we also have forgiven our trespasses; And lead us not into temptation, But deliver us from {$evil}. For thine is the {$kingdom} and the power and the glory, for ever. Amen. (END INPUT) my $path1 = Path::Tiny->cwd; say "path1 is $path1"; say "input is $input"; ## populate hash my $data = [ [ 'Our_Father', '(silence)', 'our mother', 'universal life force', 'Group Of Drunks' ], [ 'Thy_kingdom_come', 'Armageddon can wait', 'Ta ti ti ta', 'Let science be' ], [ 'evil', 'ego', 'your followers', 'being too serious' ], [ 'kingdom', 'oligarchy', 'realm', 'big blue boat' ] ]; #dd $data; ## main loop # set trials my $trials = 3; my $dummy = 1; my $first_second = strftime( "%d-%m-%Y-%H-%M-%S", localtime ); while ( $trials > 0 ) { # create an output file my $out_file = $path1->child( 'my_data', "$first_second", "$first_second\.$dummy.txt" ) ->touchpath; say "out_file is $out_file"; my %vars = map { $_->[0], $_->[ rand( $#{$_} ) + 1 ] } @{$data}; my $rvars = \%vars; my $template = Text::Template->new( TYPE => 'STRING', SOURCE => $input ) or die "Couldn't construct template: $!"; my $result = $template->fill_in( HASH => $rvars ); $out_file->append_utf8($result); $trials -= 1; $dummy += 1; } # end while condition print "OUTFILES*******************\n"; foreach my $filename ( glob("./my_data/$first_second/*") ) { open my $fh, '<', $filename or die "can't print $filename! $!"; while ( my $line = <$fh> ) { print "$line"; } say "-------------"; close $fh; } __END__