Excellent, thanks.  I wonder, though, the book I'm using,
Perl by Example, says that print individual elements of an
array, @name, to use scalars, eg. $name[1], $name[2], etc.
While your way is much easier and works well, I wonder why
my original syntax did not produce the desired result?

Joshua

> -----Original Message-----
> From: Dan Muey [mailto:[EMAIL PROTECTED]
> Sent: Thursday, August 28, 2003 2:16 PM
> To: Joshua Lokken; [EMAIL PROTECTED]
> Subject: RE: printing elements of an array
> 
> 
> > > Hello
> 
> Howdy
> 
> > > 
> > > This should be very straightforward:
> > > 
> > > print "Enter 5 of your favorite foods: ";
> > > $favorites = ( <STDIN> );
> 
> [snip]
> 
> > > 
> > > The desired output would be:
> > > 
> > > food1 food2 food3 food4 food5
> > > 
> > > food1
> > > food2
> > > food3
> > > food4
> > > food5
> > > 
> > > 
> > > Can someone steer me in the right direction?
> 
>  my @favs = split(/\s+/, $fav);
>  print @favs;
>  for(@favs) { print "-$_-\n"; }
> 
> HTH
> 
> Dmuey
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to