my @flavors = qw/sweet,sour cherry/;
yields "Possible attempt to separate words with commas" - how can I disable that warning in cases where I want literal commas?
Disable the warnings locally:
my @flavors;
{
no warnings 'qw';
@flavors = qw/sweet,sour cherry/;
}
Or, separate out those with commas:
my @flavors = ('sweet,sour', qw/cherry apple berry/);
You could use no warnings 'qw';
.
my @x = do {
no warnings qw( qw );
qw(
a,b
c
d
)
};
Unfortunately, that also disables warnings for #
. You could have #
mark a comment to remove the need for that warning.
use syntax qw( qw_comments );
my @x = do {
no warnings qw( qw );
qw(
a,b
c
d # e
)
};
But it's rather silly to disable that warning. It's easier just to avoid it.
my @x = (
'a,b',
'c',
'd', # e
);
or
my @x = (
'a,b',
qw( c d ), # e
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With