in reply to list vs array context: odd error message...
To do what split wants and to do what you want, perl has to assign the list results of the split operation to @_, then evaluate @_ in scalar context, giving you the number of elements. You might as well just use m// with your pattern in scalar context.
Your second one works because you do as swiftone recommends, creating an anonymous array out of the split results. That puts split in list context. Next, you dereference the anonymous array, and evaluate that in scalar context. Same results, except that wrapping the split in the reference/dereference stuff fools perl just enough that it doesn't give you the error message.
As for the error message, it means "Try not to do a potentially expensive operation if you're just going to throw away the results."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: list vs array context: odd error message...
by jynx (Priest) on Dec 16, 2000 at 04:45 UTC | |
by swiftone (Curate) on Dec 16, 2000 at 04:50 UTC |