How to delete characters using a file

Hi All,
I have a configuration file (file.cfg) in which data will be like this
;
,
_
+
a to z
A to Z
Now i have to read a textfile (file.txt) and i need to check whether there is any other character present in text file that is not existing in (file.cfg).
If other characters are present in text file then those characters should be deleted.

Kindly help me.

please send us the sample of two files

regards,
Sanjay

Hi ,

configuration file will contain data like this:
;
,
.
_
a
b
c to z
A
B
C to Z

Text file will contain like this:

hello;hello;[hello;
hello1;{hello1};hello1

Now in text file there are some characters which are not there in configuration file (*,{,},[). These should be deleted

what about c to z and c to Z and a,b,A and B.
Please make it very clear.or only you want to delete the special character which are not in config file.

regards,
Sanjay

---------- Post updated at 05:21 PM ---------- Previous update was at 05:17 PM ----------

if it is only regarding the special character then you can use tr command:

tr -d ';,._' < textfile

regards,
Sanjay

open CFG, "<file.cfg" or die "Unable to open file.cfg";

$hash{10} = 1;

while(<CFG>)  {
    chomp;
    if (length($_) != 1 )  {
        ($a, $b) = /^(.).*(.)$/;
        $hash{ord $_} = 1 for ($a .. $b);
    } else  {
        $hash{ord $_} = 1;
    }
}

while(<>)  {
    foreach (split //, $_)  {
        print if ( $hash{ord $_} );
    }
}

Input:

hello;*hello;[hello;hello1;{hello1};hello1*

Output:

hello;hello;hello;hello;hello;hello