TMTOWTDI:
use strict; use warnings; for ('Joe Dolly', 'perl.pl', 'States', 'Fred Fillmore Flintstone') { my @got = split; if (scalar @got > 1) { print substr($_, 0, 1) for @got; print "\n"; } }
Output:
2:16 >perl 1835_SoPW.pl JD FFF 2:17 >
(If this doesn’t accomplish what you want, you will need to explain what you’re really trying to do with that regular expression.)
Update: If you assign [] to an array, that array contains a single element, which is itself a reference to an empty array. I think you meant to rather assign () (the empty list), which leaves the array empty (zero elements).
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Split string only on regular expression match
by Athanasius
in thread Split string only on regular expression match
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |