Hi All,
I have a file called $topics_final with contents that look like this:
329/7461/301 129
329/7461/302 159
329/7461/303 116
329/7461/304 258
329/7461/305 154
329/7461/305 200
{NEWS HERE}
329/7461/311 202
329/7461/311 155
329/7461/315 47
329/7461/315 218
329/7461/315 137
329/7461/315 299
329/7461/318 15
329/7461/318 106
329/7461/322 60
329/7461/322 116
329/7461/323 328
329/7461/323 76
I also have an array called @news_topics with contents that look like this:
329/7461/1091 96
329/7461/1092 25
329/7461/1092 111
329/7461/1092 218
329/7461/1092 117
329/7461/1092 50
329/7461/1092 201
329/7461/1093 36
329/7461/1093 201
329/7461/1094 214
329/7461/1094 365
329/7461/1094 11
329/7461/1094 116
329/7461/1094 274
329/7461/1094 365
I need my script to open the file and replace the string:
{NEWS_HERE}
with the second batch of code above. Here is the subroutine I have got around this task:
#---------------------------------------------------------------------------------#
sub MERGE_DATA
{
$news = $holding_area."news";
$news_done = $news."_done";
open INPUT, "$news" or die "\n\n\n Could not open $news";
open OUTPUT, ">$news_done" or die "\n\n\n Couldn't open $news_done";
while (<INPUT>)
{
$_=~ s|//|/$issue/|;
print OUTPUT $_;
}
close(INPUT);
close(OUTPUT);
open(TOPICS, $topic_final) or die "\n\n\n Could not open topics";
@news_topics=<TOPICS>;
close(BMJ_TOPICS);
open FINAL, "$topics_final" or die "\n Cannot open $topics_final";
s/^\{NEWS_HERE\}$/@news_topics/ or print "\n\n\n NOT FOUND";
close(FINAL);
}
#---------------------------------------------------------------------------------#
This is not doing the replace as I had wished. Can anyone give me a pointer as to what code I need to get the {NEWS_HERE} string to be replaced by the contents of the array?
Many thanks
Jimbo
I have a file called $topics_final with contents that look like this:
329/7461/301 129
329/7461/302 159
329/7461/303 116
329/7461/304 258
329/7461/305 154
329/7461/305 200
{NEWS HERE}
329/7461/311 202
329/7461/311 155
329/7461/315 47
329/7461/315 218
329/7461/315 137
329/7461/315 299
329/7461/318 15
329/7461/318 106
329/7461/322 60
329/7461/322 116
329/7461/323 328
329/7461/323 76
I also have an array called @news_topics with contents that look like this:
329/7461/1091 96
329/7461/1092 25
329/7461/1092 111
329/7461/1092 218
329/7461/1092 117
329/7461/1092 50
329/7461/1092 201
329/7461/1093 36
329/7461/1093 201
329/7461/1094 214
329/7461/1094 365
329/7461/1094 11
329/7461/1094 116
329/7461/1094 274
329/7461/1094 365
I need my script to open the file and replace the string:
{NEWS_HERE}
with the second batch of code above. Here is the subroutine I have got around this task:
#---------------------------------------------------------------------------------#
sub MERGE_DATA
{
$news = $holding_area."news";
$news_done = $news."_done";
open INPUT, "$news" or die "\n\n\n Could not open $news";
open OUTPUT, ">$news_done" or die "\n\n\n Couldn't open $news_done";
while (<INPUT>)
{
$_=~ s|//|/$issue/|;
print OUTPUT $_;
}
close(INPUT);
close(OUTPUT);
open(TOPICS, $topic_final) or die "\n\n\n Could not open topics";
@news_topics=<TOPICS>;
close(BMJ_TOPICS);
open FINAL, "$topics_final" or die "\n Cannot open $topics_final";
s/^\{NEWS_HERE\}$/@news_topics/ or print "\n\n\n NOT FOUND";
close(FINAL);
}
#---------------------------------------------------------------------------------#
This is not doing the replace as I had wished. Can anyone give me a pointer as to what code I need to get the {NEWS_HERE} string to be replaced by the contents of the array?
Many thanks
Jimbo