#!/usr/bin/env perl
use strict;
use warnings;

local $/ = q{};  #enable paragraph mode.

my $sentence = qr/(?:^|\s{2})     # start of string or two spaces
                  (               # begin capturing
                  [A-Z][a-zA-Z]*  # capitalized word
                  .*?             # anything, non-greedy
                  (?:[.!?])       # punctuation
                  )               # end capture
                  (?=\s{2}|$)     # CHECK TO SEE if two spaces or end of string follow
                /sx;              # enable . to match \n as well.

my $number = qr/\d+               # integer portion
               (?:                # group decimal portion
                 \.\d+            # decimal followed by more digits
               )?                 # group may or may not exist
              /x;                 # end

my $word = qr/(?<!                # not preceded by
                [a-zA-Z]          # a letter
              )
              [a-zA-Z]{5}         # five letters
              (?!                 # not followed by
                [a-zA-Z]          # a letter
              )
             /x;

while (my $para = <DATA>) {
   my @numbers = $para =~ /^$number/mg;

   my @words   = $para =~ /$word/g;

   my @sents   = $para =~ /$sentence/g;
   #replace the newlines with spaces
   tr/\n/ / for @sents;

   {
      local $" = ', ';
      print "Numbers: @numbers\n" if @numbers;
      print "Words: @words\n" if @words;
   }

   {
      local $" = "\n";
      print "Sentences:\n@sents\n" if @sents;
   }

   print "\n";

   last if $para =~ /(?!<[a-z])end(?![a-z])/i;
}

    


__DATA__
Okay, it is now 1:00pm, and I really need to get this sample text
written.  60 students in the class are counting on me.  Well, they're not really
counting on me, they'd probably prefer to not have to do an ICA to
begin with!  Regardless, I'm going to give them one.  And in order
to do that, I need to create this sample text, don't I?

Have you ever tried just creating text?  Text that has to exist for the
sake of there being text?  It's not as easy as you might think!  In fact,
I have been doing this sort of thing for approximately
14 semesters now.  And I'll tell you, it's probably the only
1 thing about being a teacher I truly dislike.  It's not the grading
60 students assignments each week, or the holding office hours.  No,
it's definitely coming up with useless text to write.

I am sorely tempted to just use an Ipsum Lorem generator to do
this from now on!  Where would the fun be in that, you might
ask?  Well I don't know!  But I know it would be more enjoyable
than this, that's for sure.

On the other hand, if I did start using an Ipsum Lorem generator
13 times per semester, would that even work?  Could I really get
12 or 13 good assignments out of text that I'm not designing? 
I don't know.  Like this assignment, number 4, for example.  I have
to contrive the text so as to make sure that I put a floating point number like
3.14159 at the start of a line.  And another floating point number
such as 9.8 not at the start of the line, to make sure you don't match
that.  It's not as easy to remember these things as you might expect!

And now I have 5 paragraphs (okay, note quite - after all,
1 of them is still in progress.  That is probably enough, don't you
think?  I hope so, as my patience is ending.  I am sure I have plenty of 5 letter words,
and I know I have a WHOLE bunch of sentences.  And there's at least
a few numbers, yes?  Yes.  Oh, hey, there we go - a sentence containing
only one word!  Did you find it?

I may need a vacation.  End Scene.

You shouldn't have anything from this paragraph.  Remember,
you're ending your program when a paragraph
contains the word 'end' anywhere in it!
