#!/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 $_ }