Hi Stuart.

Stuart White wrote:
>
> <snip>
>
> > > Of course, then all the numbers are squished
> > together.
> > >  (How else might I say that?)
> >
> > I don't know, what do you mean by "squished
> > together"?
> >
> without spaces between each number.  (it was late last
> night and I had a mental block.)

My guess is that you're looking at the output from

  print @list;

which 'squishes' the values. Look:

  my @list = 'A' .. 'F';
  print @list, "\n";
  print "@list", "\n";

**OUTPUT

  ABCDEF
  A B C D E F

> > > So my solution is to
> > > "stringify" the array of numbers by putting the
> > array
> > > inside double quotes and assigning it to itself.
> > That
> > > seems to work.
> >
> > How does that "seem to work"?
>
> Well, it seemed to work because I thought that I was
> getting those numbers into an array, an element for
> each number.  But as you point out later, I just got
> them into the first element.
>
> <snip>
> So when I get the number from the user, I thought that
> the simplest way to get all the numbers in between was
> to use the range operator, and then store those
> numbers into an array.  Is there a way I can do that?
> Is using the range operator not a good way to go about
> getting the numbers in between and then storing them
> into an array?

Your code is exactly right: well done. You don't even need
to chomp the input:

  my $input = "  22 \n";
  my @list = (2 .. $input);
  print "list first: @list\n";

**OUTPUT

  list first: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

I hope this helps. I smell a misconception here, which may
end up with us talking at cross-purposes; but please come
back to the list if you're puzzled about anything.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to