in reply to Understanding regular expressions: why do I have to use map to clear up undefs in regex output?
Much better, IMO, to grep for only defined values (single-quotes used in example instead of double-quotes to avoid lots of escaping on XP command line):
>perl -wMstrict -MData::Dumper -le "my $str = q{1,2,3,4,'fine', '', 'day','today',}; my @f = grep defined, $str =~ m{ (\d+) | ' ([^']*) ' }xmsg ; print Dumper \@f; " $VAR1 = [ '1', '2', '3', '4', 'fine', '', 'day', 'today' ];
|
---|