Trying to learn programming on your own is a daunting task. I suggest getting a beginning book, perhaps "Perl for Dummies". I think you can get a used copy of this at a reasonable price. There are other books, but a lot of them start off too quickly for someone with no programming experience. I congratulate you on trying to learn a new skill.

Here is some code for you to play with. There are many flaws in this, but I think you just wanted a simple demo of an input loop.

#!/usr/bin/perl use warnings; use strict; my $numbers = "2 1 3 4 5"; my @numbers = split(' ', $numbers); print "numbers are: @numbers\n"; my $input; print "Enter numbers 1-5, q to quit:\n"; while ($input =<STDIN>, $input !~/q/i) { chomp $input; #needed to get rid of line ending print "the $input th num: $numbers[$input-1]\n"; } print "program completed\n"; __END__ numbers are: 2 1 3 4 5 Enter numbers 1-5, q to quit: 3 the 3 th num: 3 5 the 5 th num: 5 q program completed
Update: saw this free beginning Perl online book. Price is right! Still goes very quickly for a non-programmer.

In reply to Re: Nth position of array determind by <> by Marshall
in thread Nth position of array determind by <> by RuZombieSlayer

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.