develooper Front page | perl.beginners | Postings from August 2003

Fw: newbie: printing elements of an array

From:
Joshua Lokken
Date:
August 28, 2003 13:26
Subject:
Fw: newbie: printing elements of an array
Message ID:
003301c36da2$0fc871f0$0104e9c6@Joshua

----- Original Message ----- 
From: "Jolok" <inspector.us@omicnet.com>
Newsgroups: perl.beginners
Sent: Thursday, August 28, 2003 1:19 PM
Subject: newbie: printing elements of an array


> > Hello
> >
> > This _should_ be very straightforward:
> >
> > print "Enter 5 of your favorite foods: ";
> > $favorites = ( <STDIN> );
> > @foodlist=split(' ', $favorites);
> > print "@foodlist\n";
> > print "$foodlist[0]\n";
> > print "$foodlist[1]\n";
> >   ...
> >
> >
> > But I am getting (as output):
> >
> > food1 food2 food3 food4 food5
> >
> > food1 food2 food3 food4 food5
> >
> >
> >
> >
> >
> > end of output
> > So, I'm guessing that the 'split' command is used incorrectly?
> >
> > The desired output would be:
> >
> > food1 food2 food3 food4 food5
> >
> > food1
> > food2
> > food3
> > food4
> > food5
> >
> >
> > Can someone steer me in the right direction?
> 
> --
> Best Regards,
> 
> Joshua Lokken
> OMIC Portland Branch
> inspector.us@omicnet.com
> (503) 807-6538
> -------------------------------------------->
> 
> 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About