On Fri, Apr 30, 2004 at 10:44:14AM -0700, Ken Gosier wrote:

> In this case, @F will only contain 3 entries, since split
> will not count the trailing null entries. This screws up my
> code later on. It'd be much easier to assume @F always has
> 6 entries.
> 
> By reading perldoc -f split, I wasn't able to find a way to
> make split count those entries. Is there a way to make
> split count trailing null entries?

It's in there:

    If LIMIT is specified and positive, it represents the maximum number of
    fields the EXPR will be split into, though the actual number of fields
    returned depends on the number of times PATTERN matches within EXPR.
    If LIMIT is unspecified or zero, trailing null fields are stripped
    (which potential users of "pop" would do well to remember).  If LIMIT
    is negative, it is treated as if an arbitrarily large LIMIT had been
    specified.  Note that splitting an EXPR that evaluates to the empty
    string always returns the empty list, regardless of the LIMIT
    specified.

my @F = split ',', $line, -1;

Ronald
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to