$ cat fears2.txt
0. Dying
1. Abject poverty
2. Being homeless
3. Cancer, disease
$ cat causes2.txt
0. It's everyone's greatest terror, likely laden with pain.
1. My earning power has been decreasing and a regime is on the ascendance that wants to crush my class.
2. It's awful and the result of 1.
3. It runs in the family and can happen spontaneously with appreciable probability. It's expensive.
$
####
#!/usr/bin/perl -w
use strict;
use 5.010;
use lib "template_stuff";
use steps1;
# main data structure
my %vars = (
fears => 'fears2.txt',
causes => 'causes2.txt',
width => 50,
);
my $rvars = \%vars;
my $return = pop_texts( $rvars );
say "returned was \n $$return";
__END__
####
package steps1;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(
pop_texts
);
sub pop_texts {
use strict;
use 5.010;
use File::Slurp;
my ($rvars) = shift;
my %vars = %$rvars;
my @fears = read_file( $vars{fears} );
my @causes = read_file( $vars{causes} );
for (@fears) {
s/\s+$/ /;
}
for (@causes) {
s/^\d+\./exists because/;
}
#say "causes are @causes";
my $text1 ='';
for my $i ( 0 .. $#causes ) {
$text1 = $text1 . $fears[$i] . $causes[$i] . "\n";
}
my $reftext = \$text1;
return $reftext;
}
1;
####
$ perl fears1.pl
returned was
0. Dying exists because It's everyone's greatest terror, likely laden with pain.
1. Abject poverty exists because My earning power has been decreasing and a regime is on the ascendance that wants to crush my class.
2. Being homeless exists because It's awful and the result of 1.
3. Cancer, disease exists because It runs in the family and can happen spontaneously with appreciable probability. It's expensive.
$