So I have this assignment for a beginner course in Perl and I have done some stuff and they worked out good, but i’ve totally run into a brick wall here and I can’t get any further, and my guess is the answer is really simple only that I can’t seem to fix it.
I have a text file with some text in it, simply what I’m trying to do is write the content of that file to the Terminal, this I can do with
open (DATA, "example.txt") or die "an error occured: $!";
while(<DATA>)
{
print "$_\n";
}
But, I also need to add numbering to each line of the output and I’m trying with $. but that only gives me a “1” as an output, I have been trying different stuff here all morning but I can’t seem to figure this out.
What I want is an output that looks like this:
- Lorem ipsum dolor sit amet
- consectetur adipiscing elit
- Maecenas iaculis vulputate eros
- —-
- —-
And so on.
Anyone that can help me out with this?
To start a new line after every sentence (full stop followed by at least one blank), you could use something like the following:
(Very likely there is a better perl idiom for this …)