#!/usr/bin/perl
# ------------------------------------------------------------
# Dateiname:        $Source: /ma/miwa/CvsRepository/mjm/tools/Development/mergeFiles.pl,v $
# Version:          $Revision: 1.1.1.1 $
# Datum geaendert:  $Date: 2002/04/11 14:37:04 $
# Komponente:       MNPC_Tools
# Kommentar:        Hilfsskript zur Erzeugung von ActionAdapter
#
# Autor 1:          Michael J.M. Wagner, sd&m AG
# Autor 2:          $Author: mnpcd4wl $
# Status:           $State: Exp $
# Copyright (c):    ViagInterkom, Februar 202
# ---------------------------------------------------------

#---------------------------------
# Hauptprogramm
#---------------------------------

# check input params
if ($#ARGV != 2)
{
    die "usage: mergeFiles.pl <insertion> <envelope> <TAG>"
}

# Lese envelope file
open (INSERTION_FILE, $ARGV[0]);
@Insertion = <INSERTION_FILE>;

# Lese envelope file
open (ENVELOPE_FILE, $ARGV[1]);
@Envelope = <ENVELOPE_FILE>;

# merge files
open (COUT, ">MF.tmp");
foreach $EnvLine (@Envelope)
{
	chomp($EnvLine);
	if ($EnvLine eq $ARGV[2])
	{
		# TAG found : insert
		print COUT @Insertion;
	}
	else
	{
		# print line
		print COUT "$EnvLine\n";
	}
}
system ("mv MF.tmp $ARGV[1]");