use Data::Dumper; use strict; my @keywords = qw(auto continue enum if short break switch volatile de +fault extern int signed typedef while case do float long sizeof union + char double for register static unsigned const else goto return stru +ct void); my $keywords_re = join '|', @keywords; my $file = '/home/vikash/maya/new.c'; open my $fh, $file or die $!; my %keywords; while (<$fh>) { while (m{\b($keywords_re)\b}g) { $keywords{$1}++; } } print Dumper(\%keywords);
In reply to Re: how to automate the regular expression match from a file?
by wind
in thread how to automate the regular expression match from a file?
by vikashiiitdm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |