$h4X4_|=73}{ has asked for the wisdom of the Perl Monks concerning the following question:
I found out something strange about split. I guess it will not parse blank content till there is something at the end...
I have a string that splits at a comma,but when there are repeated delimiters at the end they will not be added to the array till there is something at the end like so...
Any other ways maybe regex or should I trick the array and then pop the last content out?#!perl use warnings; use strict; use Data::Dumper; my $str = "ABC,123,,,,,,"; # just ABC and 123 #my $str = "ABC,123,,,,,,this"; # now it shows the blanks. my @elems = split ',', $str; print Dumper \@elems;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Do I have to trick Split?
by BrowserUk (Patriarch) on Aug 20, 2016 at 12:17 UTC | |
by perldigious (Priest) on Aug 23, 2016 at 12:55 UTC | |
by BrowserUk (Patriarch) on Aug 23, 2016 at 14:30 UTC | |
by TomDLux (Vicar) on Aug 23, 2016 at 16:09 UTC |