![]() |
|
P is for Practical | |
PerlMonks |
Re: Split problem using limitby davido (Cardinal) |
on Aug 20, 2004 at 15:17 UTC ( #384615=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|