I typed in 3. For example, "Sam Mary Joe". I expect to get "I know Mary", since she's [1] but I'm getting a blank space. I've tried this on NT and on my 98 machine here at work.
-----Original Message----- From: Paul Johnson [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 25, 2003 9:13 AM To: Anthony Beaman Cc: [EMAIL PROTECTED] Subject: Re: Array Question Anthony Beaman said: > Hi! I'm still wallowing in Chapter 3 (Arrays. Why can't I get it?!?!?!? > ARGH!!!!!) of Learning Perl on Win32 Systems. I'm trying to create an > exercise but I'm not getting the results that I want. Here's what I'm > trying to do: > > I'm asking for a list of names: > > print "Name your friends: "; > @names = <STDIN>; > > Then I want to pretend that I know the one of the friends. In this case, > I'll choose the 2nd one and here's where I'm not getting what I want: > > print "I know $names[1].\n"; > > The output shows "I know ." > > Isn't "$names[whatever]" what I'm supposed to use to get an element of the > array? I've tried this with numbers and have gotten the same results. What > am I doing wrong? Thanks! :-) How many names did you type in? $names[1] is the second element of the array because arrays start at zero by default, so you will need to type in at least two names. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]