Use
\b to assert a word boundary then.
my $word = qr/\b(directory|file|age|action)\b/;
Or
^ and
$ to assert string start/end (respectively).
my $word = qr/^(directory|file|age|action)$/;
Or any combination of the two that you like. See
perldoc perlre.
Makeshifts last the longest.