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