The presence of initial spaces forces the empty string as the first element. That effect is suppressed for trailing match, but the initial match is regarded an a separator.
The magical split trims leading and trailing whitespace, so is probably what you want:
$ perl -MData::Dumper -e ' > $str = " STRING "; > @ar = split(" ", $str); > print Dumper \@ar;' $VAR1 = [ 'STRING' ]; $
After Compline,
Zaxo
In reply to Re: Nagging space after splitting
by Zaxo
in thread Nagging space after splitting
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |