veerubiji has asked for the wisdom of the Perl Monks concerning the following question:

I want add some information to c file. I have two hash tables one hash table contains information about some strings and numbers to stings like as shown below.

hash table1 (keys)(string nubers) (values)string names 24 temperature 25 pressure 26 humidity

like this i have more strings and regarding numbers. in this hash table keys are numbers and values are string names. i have another hash table which contains string numbers and information.

hash table 2 (keys)(string nubers) (values)string names 24 information 25 information 26 information.

like that i have second hash table. numbers in the both hash tables are same and each string having unique number.there is no repetion in numbers like 1 to 100 numbers. now in my c file i have the sting names like temperature and humidity and pressure..... i have to search that string using these hash tables and i have to add information after the string if i found any string in the c file. i have written code like this but its notworking.

#!/usr/bin/perl use warnings; use strict; open (my $code , "<", 'ccode.c'); my %data = ('24'=>":&temperature \n", '25'=>": &pressure \n", '26'=>": &humidity\n", ); my %nums = ( '24'=>": information1\n", '25'=>": information2 \n", '26'=>": information3 \n", ); my $test_string="(" .join("|", keys %data).")" ; while(<$code>){ if (/$test_string/){ chomp; %data= reverse %data; $_.=$nums{$data{1}}; } print $_ }

if i excute this script it doesnt give any errors and no added information in the c file. it giving original c file as it is.what should i have to change in this code. my c file is lokking like as below.