in reply to keeping split deliimiters causing empty string elements
Hello previous,
TMTOWTDI: Put the separator in a single capture group:
use strict; use warnings; use Data::Dump; my $eqn = '$profit=$sales-$cogs'; my @wrds = split /(=|-)/, $eqn; dd \@wrds;
Output:
23:13 >perl 1596_SoPW.pl ["\$profit", "=", "\$sales", "-", "\$cogs"] 23:13 >
See the final paragraph of split.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: keeping split delimiters causing empty string elements
by previous (Sexton) on Apr 15, 2016 at 17:59 UTC |