#!/usr/bin/perl use warnings; use strict; my $code = *DATA; my %data = (24 => 'temperature', 25 => 'pressure', 26 => 'humidity', ); my %nums = ( 24 => ": information1\n", 25 => ": information2 \n", 26 => ": information3 \n", ); %data = reverse %data; my $test_string = '(' . join("|", keys %data) . ')' ; while (<$code>){ if (/$test_string/) { chomp; $_ .= $nums{$data{$1}}; } print; } __DATA__ /*! ***************************************************************************** * * $b Description: Pressure Valve high ****************************************************************************/ #include "ccode.h" /****************************************************************************/ /* Local function prototypes (static): */ void main_10ms(void) { temperature ( i need to add infomation before string that found) if {..... ...... if{........ ..... }else {...... } } humidity( i need to add infomation before string that found) if {..... ...... if{........ ..... }else {...... } }