previous has asked for the wisdom of the Perl Monks concerning the following question:
my $eqn='$profit=$sales-$cogs'; my @wrds = split /(=)|(-)/, $eqn; #gives profit,=,,$sales,,-,$cogs my $wrds_str=join(",",@wrds); $wrds_str =~ s/,,/,/g; @wrds = split /,/, $wrds_str; print join ",",@wrds;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: keeping split delimiters causing empty string elements
by Athanasius (Archbishop) on Apr 15, 2016 at 13:15 UTC | |
by previous (Sexton) on Apr 15, 2016 at 17:59 UTC | |
|
Re: keeping split deliimiters causing empty string elements
by BrowserUk (Patriarch) on Apr 15, 2016 at 13:13 UTC | |
by previous (Sexton) on Apr 15, 2016 at 18:01 UTC | |
|
Re: keeping split deliimiters causing empty string elements
by AnomalousMonk (Archbishop) on Apr 15, 2016 at 14:26 UTC | |
by previous (Sexton) on Apr 15, 2016 at 17:58 UTC |