Robert Krueger wrote: > Hi, Hello,
> I bought 3 books a few days ago on Perl, and things are going well with > one exception. > > An example: > > @line = "this is a very long line word1+word2+word3 and it contines on and > on"; > > The object is to execute a split using "+" so I end up with word1, word2, > and word3, so I do this: > > my @line = split('\+'); > > According to the books, I should end up with this: > $line[0] = word1 > $line[1] = word2 > $line[3] = word3 > > Instead it ends up to be this: > $line[0] = this is a very long line word1 > $line[1] = word2 > $line[3] = word3 and it contines on and on > > I can't figure out what I'm doing wrong. > Can someone explain? You are not doing anything wrong, that is how split() works, everything upto the first '+' is put into $line[0] and everything between the first and second '+' is put into $line[1] and everything between the second and the third '+' is put into $line[3], etc., etc. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>