http://qs1969.pair.com?node_id=135265


in reply to How can I use 'split' with unknown amount of variables?

It's hard to tell exactly what you're asking. Do you just want to know how many elements are returned to you? Easy. Do as others have suggested: split to an array and then find the number of elements it contains. You don't necessarily need to assign variables; just use the array elements directly.
@list = split /\|/, FuncThatGivesData(); print "Found ", scalar(@list), " elements\n"; $i = 0; foreach $e (@list) { print "Element $i: $list[$i]\n"; $i++; }
Do you need to know which variables came back? Your example, "key|title|date|author|news", could be interpreted as a regular expression (i.e., "key OR title OR date...") or as a literal string, where '|' is the separator. If '|' is the separator, follow the example above. If you really are asking how to tell which pieces of data were returned, you need some kind of header to idenfity the fields, and it's a somewhat more complex problem.

Can you be more specific with your question?