Hello monks,

I'm making a series of lists that I want to cobble together and eventually be able to print out with some reasonable spacing and formatting. If the process works, eventually, this particular list of things I fear will grow smaller and more-manageable. For the purpose at hand, I am to read them to a third party when I'm done compiling them, so I will have to have a hard copy that would come from a windows-based machine. I notice that anything I print off now that I've written on this linux partition gets rendered without any carriage returns, so that's definitely an issue. I've decided to handle them as arrays, so I've made my lists to begin with 0:

$ 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 ascenda +nce 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. $

I zip these together with "exists because" between item and same-numbered cause. Here's the caller, callee, and output:

#!/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. $

Q1) How do I change the unwanted capitalization of the beginning letter in the cause?

Q2) How do I constrain the text to the width indicated in the main data structure, and on a windows machine? Should I use a differing file extension?

Thanks for your comment,


In reply to combining lists, formatting and printing on windows by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.