A Diumenge 10 Setembre 2006 01:56, Robert Krueger va escriure: > Hi, > 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? > > Thanks, > Robert
Syntax of split function is: @fields = split /separator/, $string; (using default split is: @fields = split;). Using 'separator' you're taking a literal as a separator. -- Xavier Mas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>