Try this. Note the comments in the code and see below for some references for further reading:
#!c:/perl/perl.exe # ALWAYS use strict and warnings (see: strict, warnings) use strict; use warnings; # In general, keep comments on separate lines from your code # the first line in the world of perl. print "My first Perl script\n\n"; # Declare the variables, and make them descriptive my ($multiplier, $max_number); # Get some input from the user # Lets also validate it (we are only interested in "numbers") # See perlre & perlretut while (1) { print "Please tell me the multiplication table required: "; chomp($multiplier=<STDIN>); # If it's a number, exit the loop last if $multiplier =~ /^\d+$/; } # Same as above while (1) { # The following line wraps in a standard DOS window, so lets sprea +d it # over a couple of lines print "Please tell me the multiplication Factor\n", "(if you put more than 100, make sure you have a big screen!) + : "; chomp($max_number=<STDIN>); last if $max_number =~ /^\d+$/; } # Now, print out the table # Use a "perlish" loop rather than a C-style one # By doing it this way, we don't need the loop variable # And we can instead just operate on $_ print "\nThe table is:\n\n"; for (1 .. $max_number) { print "$_ X $multiplier = ", $_*$multiplier, "\n"; }
References: strict, warnings, chomp, perlre, perlretut, print

Cheers,
Darren :)


In reply to Re: Advice on First Perl Script by McDarren
in thread Advice on First Perl Script by hozefa

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.