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

In reply to Re: First Run by Lotus1
in thread First Run by TheloniusMonk

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.