in reply to First Run

#!/usr/bin/perl use strict; use warnings; my @words = <DATA>; chomp @words; my $length = 5 + 20*rand(); { use integer; $length += 0; }

Why use integer for one line? The documentation for rand() shows exactly how to do the same thing with int().

for my $line (0..$length) { #prints length + 1 lines.

There is an off by one error here since 0 to $length is $length+1 lines.

$line and print ".-$line.\n";

Printing the last character on the first line of the loop is silly. You end up needing another print to put in the period for the last line.

my $width = int( 9*rand() ); { use integer; $width++; }

This doesn't change $width to an integer. Refer to integer

Now, it so happens that the pre- and post- increment and decrement operators, ++ and --,
are not affected by use integer; either. Some may rightly consider this to be a bug --
but at least it's a long-standing one.

for my $word ( 0..$width ) {

Another off by one error.

my $where = $#words * rand();

This will never pick the last element in the array.

{ use integer; $where += 0; } my $choose = $words[$where]; unless ($word) { $choose =~ /^(.)(.*)$/; $choose = uc($1) . $2; }

If you don't want to use ucfirst() then s/^(.)/\u$1/ would be simpler.

$word and $choose = " $choose"; print $choose; } } print ".\n"; __DATA__ 2 1080 &c 10-point 10th 11-point 12-point etc. for rest of English words

Replies are listed 'Best First'.
Re^2: First Run
by TheloniusMonk (Sexton) on Sep 05, 2018 at 06:44 UTC
    Many thanks for the review!!!