using Variable in grep in perl
I have a situation where i have a file with values in that, Something like below.
I have a variable "$ELEMENT" holding these values, Now i need pass these variable values in grep statement to get messages having these numbers from one file(text1.dat) and create new one(text2.dat).
Below is my grep statement in perl.
system("grep -h \"$ELEMENT\" text1.dat >> test2.dat");
I know the grep statement in not true, Because i cannot pass variable there. I am not sure how to use variable in grep in perl code.Any suggestions??