Im storing multiple functions in a varaible called $check...
The variable check contains the following:
a()
b()
c()
...
..etc
now im checking individually which function is kept in which file using GREP
if ( grep \$check \i, <FILE> )
The problem is im getting the output for the following functions also:
a(
a();
b(
b();
How to match only a()
b()
c()
etc..etc..using the grep..
Something like this?
$ cat input
a()
b()
$ cat input2
b()
$ cat input3
c()
[highlight=perl]#! /usr/bin/perl -w
use strict;
my @check = qw / a() b() c() /;
my @files = glob "input*";
my ($fl, $fn);
for $fl (@files) {
for $fn (@check) {
open I, "< $fl";
if (grep {/$fn/} <I>) { print "$fl contains $fn\n" }
close I;
}
}[/highlight]
$ ./test.pl
input contains a()
input contains b()
input2 contains b()
input3 contains c()