Okay, so there is an input form, with 4 text boxes. I get the input using CGI.pm:
my $exc0 = param('exclude0') || 'a';
my $exc1 = param('exclude1') || 'a';
my $exc2 = param('exclude2') || 'a';
my $exc3 = param('exclude3') || 'a';
The reason I had to include the || 'a'
is to allow it to work if there was no input. Is there a safer way to do this?
It gets called later on in a regex:
next if ($totalmatch->[2] =~ /\b$exc0\b/i);
next if ($totalmatch->[2] =~ /\b$exc1\b/i);
next if ($totalmatch->[2] =~ /\b$exc2\b/i);
next if ($totalmatch->[2] =~ /\b$exc3\b/i);
Where $totalmatch->[2]
is a sentence. If I don't check for no input, when there isn't an input no matches come up (a.k.a. it includes $exc
in every case). I'd guess this is because there is an undef or space in every sentence?
What I've tried is || ''
and I suppose I could use a if ($exc0)
or a if defined()
or eq ''
but just looking for help.
Thanks a lot for your time.