use warnings;
use strict;
use Regexp::Assemble;
my @keywords = qw(
a an the then that this
);
my $key_rea = Regexp::Assemble->new;
$key_rea->add($_) for @keywords;
my $key_re = $key_rea->re;
my $data = do { undef $/; };
print "$1\n" while $data =~ m/(\b$key_re\b)/g;
__DATA__
hello everyone, i had been trying to make a lexical analyzer for c, where all the keywords were to be inputted in a text file keywords. this i stored in an array. but this process is not being automated. the code i wrote is as follows :-
...
the keywords file contains:- auto continue enum if short break switch volatile default extern int signed typedef while case do float long sizeof union char double for register static unsigned const else goto return struct void