
Laurent_R
Enthusiast
Aug 19, 2012, 2:01 PM
Post #2 of 14
(2782 views)
|
|
Re: [jazzo] insert numbers in array using standard input
[In reply to]
|
Can't Post
|
|
Hi, you are taking it the wrong way, if I understand what you want correctly. in:
my @array = qw|first second third fourth|; you are giving values to the first fourth elements of your array. It is unlikely that is what you are rally trying to do. (BTW, "first" will be the value of $array[O], "second the value of $array[1], and so on. This is also presumably not what you want. Now, you have basically two ways of handling your problem. You can loop through the array, and, for each element of this array, ask your user what she or he wants for a value. Or you want your user to enter a string aith all the value, for example something like "17, 13, 7, 9876, 1" (or possibly "17 13 7 9876 1", or whatever) and then assign each number with proper code to do it. Both approaches are feasible and quite easy. It is up to you to decide on how vou want to do it. Obviously, the coding will be different depending on how you expect your user to enter the data.
|