|go ahead... be a heretic|
Split(), Initial Spaces, & a limit?by cmv (Chaplain)
|on Jul 20, 2010 at 15:44 UTC||Need Help??|
cmv has asked for the
wisdom of the Perl Monks concerning the following question:
I'm having difficulty figuring out how to get split to do its job with data that has initial spaces, when I need to set a limit.
Consider the following:
This works wonderfully (as stated in the Camel book), the initial spaces in the data are ignored and each call to split returned a list with two elements!
Now, I would like to add a limit to the number of fields that split will split on. Notice the changes in the data below, and I still want each split to return a list with two elements:
Well, split is returning a list with two elements in every case, but in the case of the lines with initial spaces, it returns a null for the first element.
How can I get the second case to ignore leading spaces like the first case did?