http://qs321.pair.com?node_id=384615


in reply to Split problem using limit

Using a limit with split tells split to return only that number of elements. However, that doesn't mean that split should skip the step of splitting. If I understand you're problem, you are trying to get split to not split, some of the time.

Using a limit of zero won't help you. According to perldoc -f split: "If LIMIT is unspecified or zero, trailing null fields are stripped (which potential users of pop would do well to remember)." As you can see, this has nothing to do with getting split to keep the entire line in tact.

Perhaps you should be performing whatever check you're using to determine whether or not to split, and then if the check is positive, don't invoke split on that line at all.

Also, your first experiment (  split(0) ) can't work. You can't just leave off preceeding arguments from a subroutine and expect that Perl will know that you really intend the single arg you've provided to take the third arg's position. That falls under the category of "You can't just make sh#@ up and expect it to work..."


Dave