in reply to Re: Blank File
in thread Blank File

Specifying -1 as the third argument to split causes it to not discard trailing empty results, which is not the default behavior.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: split,,-1 (Re: Blank File)
by tadman (Prior) on Jan 26, 2001 at 00:01 UTC
    True, but the presence or absence of '-1' as a paremeter as used in that program would have no effect, correct? If I understand the documentation correctly, the '-1' is important in very specific circumstances, such as using pop():
    my ($a) = "the|sneaky|camel||"; my (@b, $nil); # Try different parameters with split and report for my $p (undef, -1) { @b = split (/\|/, $a, $p); ($nil) = pop (@b); print "split() with '$p': '$nil' should be empty, ", (length($nil)?" but isn't":"and is"),".\n"; }
    You learn something new every day, it seems.