rjohn1 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I have the following code. With my basic understanding of split, i thought that the o/p would be an array with 4 elements as : (,allon,native,).
But the result array after split contains only 3 elements. Why does it not have the 4th(empty) element.
my $str = ";allon;native;;"; my @arr = split /;/, $str; my $indx = 0; foreach (@arr){ print "$indx:$_\n"; $indx++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question regarding split
by BrowserUk (Patriarch) on Jan 20, 2014 at 07:03 UTC | |
by Anonymous Monk on Jan 20, 2014 at 10:12 UTC | |
|
Re: Question regarding split
by sn1987a (Curate) on Jan 20, 2014 at 16:15 UTC | |
by rjohn1 (Sexton) on Jan 21, 2014 at 03:02 UTC | |
|
Re: Question regarding split
by Lennotoecom (Pilgrim) on Jan 20, 2014 at 07:24 UTC |