Subject: | Warining in parse_options() due to improper use of Regexp::Common |
Hi,
the following test case produces a warning for me:
use Net::IMAP::Server::Command;
use strict;
use warnings;
my $c = new Net::IMAP::Server::Command;
$c->parse_options ('MESSAGES UNSEEN YOLO UIDVALIDITY UIDNEXT');
Use of uninitialized value $_ in pattern match (m//) at lib/Net/IMAP/Server/Command.pm line 141.
The problem lies in the following code:
grep {/\S/}
split
/($RE{delimited}{-delim=>'"'}{-esc=>'\\'}|$RE{balanced}{-parens=>'()'}|\S+$RE{balanced}{-parens=>'()[]<>'}|\S+)/,
Regexp::Common returns a regular expression with a capture group and split() considers it to be a separator, resulting in undefined strings being fed to grep():
$ perl -e 'use Regexp::Common "RE_ALL"; print RE_balanced(-parens=>"<>");'
(?^:((?:\<(?:(?>[^\<\>]+)|(?-1))*\>)))
^^^^^ a capture group here.
A quick way to silence it it the following:
- grep {/\S/}
+ grep {defined $_ and /\S/}
though I don't know whether the code functions as intended. I have no better idea though.