This makes a lot of sense and I think it may be the solution BUT my Ctr-z isn't 
working on my machine! I'm on Win98 and when I press ctrl-z it goes to a DOS prompt 
(no output). Any ideas on fixing this? If not, I can try this on my NT machine at 
home. 



                -----Original Message-----
                From:   Rich Fernandez [mailto:[EMAIL PROTECTED]
                Sent:   Wednesday, June 25, 2003 9:30 AM
                To:     Anthony Beaman
                Cc:     [EMAIL PROTECTED]
                Subject:        RE: Array Question

                Hi Anthony,

                LF (\n) is the default record separator, so if you type 3 names and 
press
                enter, 
                all 3 names get placed in $array[0].

                The next item(s) get placed in $array[1], etc depending on where you 
press
                enter.

                If your input looks like this:
                Fred Barney <enter>
                Wilma Betty <enter>

                your program will print "Wilma Betty" because each <enter> will add a 
LF.

                HTH

                richf 

                -----Original Message-----
                From: Anthony Beaman [mailto:[EMAIL PROTECTED]
                Sent: Wednesday, June 25, 2003 9:18 AM
                To: Paul Johnson
                Cc: [EMAIL PROTECTED]
                Subject: RE: Array Question


                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]

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to