Hi,
i have one hash tables that contains data stings and information. I have one c file , i need to search the file and if i found stings in the c file i need to add information at the top of the c file. I am very beginer to perl, i have written code like this
code:
#!/usr/bin/perl
use warnings;
use strict;

open (my $code , "<", 'c.c');

my %strings = ('string1'=>"information \n",
'string2'=>"information2 \n",
'string3'=>"information3 \n",
);


my $test_string="(" .join("|", keys %strings).")" ;

while(<$code>){

if (/$test_string/){

chomp;


$_.=$strings{$1};
}
print $_
}

this code adding the information before the string, i need to add at the top of the c file. what should i do in this case.