#!usr/perl/bin -w use warnings; use strict; use diagnostics; use POSIX; ################################## #Global variable declarations ################################## my $file_431_inp = "kwd_431.txt"; my $file_471_out = "kwd_471.txt"; my $file_471_final_out = "MMS_KWD_4.71_CONVERTED.txt"; my $val; my $sbsb_id_431; my $sbsbid; my $i = 0; my $j = 0; my $sbsb_id_431_cnt = 0; my $sbsb_loop_cnt_471 = 0; my $sbsb_loop_cnt_471_act = 0; my $remainder = 0; my $eof = '@pRECTYPE="LEOF"'; my @file_431_arr = (); my @file_471_org_arr = (); my @file_471_upd_arr = (); my @file_471_fin_arr = (); my @file_sbsb_upd_arr = (); my @eof_arr = (); my @temp = (); ############################################################################# #No of Records / Subscriber(SBSB)loops in the Input Facets 4.31 KWD file ############################################################################# open(INPFILE, "<$file_431_inp") || die ("Could not read the file"); @file_431_arr = ; close(INPFILE); for ($i=0;$i<$#file_431_arr;$i++){ if ($file_431_arr[$i] =~/(^\@pRECTYPE="SBSB")(\S*)/){ if ($file_431_arr[$i] =~/(\@pSBSB_ID=")(\d{9})/){ $sbsb_id_431 = $2; $sbsb_id_431_cnt = $sbsb_id_431_cnt + 1; } } } print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Number of Records / Subscriber(SBSB)loops in the Input Facets 4.31 KWD file is : $sbsb_id_431_cnt\n\n"; ############################################################################ #Getting user Input for number of desired Duplicates in the output 4.71 file ############################################################################ print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Enter the number of Records / Subscriber(SBSB)loops desired in the output KWD 4.71 file.To obtain the most accurate results enter a value which is a multiple of $sbsb_id_431_cnt\n\n"; $val = ; $sbsb_loop_cnt_471 = int ($val / $sbsb_id_431_cnt); $remainder = ($val % $sbsb_id_431_cnt); $sbsb_loop_cnt_471_act = ($val - $remainder); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Creating output Facets 4.71 MMS KWD file with $sbsb_loop_cnt_471_act Records / Subscriber(SBSB)loops\n\n"; ############################################################################ # Duplicating the contents of the Input Facets 4.31 KWD file ############################################################################ open(INFILE, "<$file_431_inp") || die ("Could not read the file"); my @file_431_org_arr = ; close(INFILE); for ($j=0; $j<$sbsb_loop_cnt_471; $j++){ push (@file_471_org_arr,(@file_431_org_arr)); } open(OUTFILE, "+>$file_471_out") || die ("Could not open the file in write mode"); print OUTFILE (@file_471_org_arr); close(OUTFILE); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: $sbsb_loop_cnt_471 duplicates of the input 4.31 KWD file successfully created with a total record count of $sbsb_loop_cnt_471_act\n\n"; ############################################################################# # Implementing 4.71 changes, printing the WMDS_SEQ_NO segments to new lines ############################################################################# open(UPDFILE, "<$file_471_out") || die ("Could not read the file"); open(SBSBUPDFILE, "+>$file_471_final_out") || die ("Could not open the file in append mode"); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: 4.71 changes implementation initiated\n\n"; foreach (){ if ($_ =~ /^(\@pRECTYPE=\"SBSB\")(.*)(\@pWMDS_SEQ_NO)(1)(=\d{1})(.*)(\@pWMDS_SEQ_NO)(2)(=\d{1})(.*)(\@pWMDS_SEQ_NO)(3)(=\d{1})(\,)(.*)$/){ print SBSBUPDFILE "$1$2$15\n"; push (@temp, $1); push (@temp, $2); push (@temp, $3); push (@temp, $4); push (@temp, $5); push (@temp, $6); push (@temp, $7); push (@temp, $8); push (@temp, $9); push (@temp, $10); push (@temp, $11); push (@temp, $12); push (@temp, $13); push (@temp, $14); push (@temp, $15); } elsif ($_ =~ /^\@pRECTYPE=\"MEME\"/){ print SBSBUPDFILE $_; if ($temp[4] ne '=0'){ print SBSBUPDFILE "\@pRECTYPE=\"MEWM\"\,\@pMEWM_UPDATE_CD=\"AP\"\,$temp[2]$temp[4]\,\@pMEWM_EFF_DT=\"01/01/1900\"\,\@pMEWM_TERM_DT=\"12/31/9999\"\,\@pMEWM_MCTR_TRSN=\" \"\n"; } if ($temp[8] ne '=0'){ print SBSBUPDFILE "\@pRECTYPE=\"MEWM\"\,\@pMEWM_UPDATE_CD=\"AP\"\,$temp[6]$temp[8]\,\@pMEWM_EFF_DT=\"01/01/1900\"\,\@pMEWM_TERM_DT=\"12/31/9999\"\,\@pMEWM_MCTR_TRSN=\" \"\n"; } if ($temp[12] ne '=0'){ print SBSBUPDFILE "\@pRECTYPE=\"MEWM\"\,\@pMEWM_UPDATE_CD=\"AP\"\,$temp[10]$temp[12]\,\@pMEWM_EFF_DT=\"01/01/1900\"\,\@pMEWM_TERM_DT=\"12/31/9999\"\,\@pMEWM_MCTR_TRSN=\" \"\n"; } } else{ print SBSBUPDFILE $_; } } close(UPDFILE); close(SBSBUPDFILE); print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: 4.71 changes implemented successfully\n\n"; ############################################################################# # Generating unique SBSB IDs ############################################################################# print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Generation of unique SBSB IDs initiated\n\n"; open(SBSBUPDFILE, "<$file_471_final_out") || die ("Could not open the file in read mode"); my @sbsb_upd_471 = ; close(SBSBUPDFILE); open(SBSBUPDFILE, "<$file_471_final_out") || die ("Could not open the file in read mode"); while (){ if ($_ =~ /(\@pSBSB_ID=")(\d{9})/){ $sbsbid = $2; last; } } close(SBSBUPDFILE); my $flag = 0; for ($i = 0;$i<= $#sbsb_upd_471; $i++){ if ($sbsb_upd_471[$i] =~ /(\@pSBSB_ID=")(\d{9})/){ $sbsb_upd_471[$i] =~ s/\d{9}/$sbsbid/; $sbsbid++; } } open(SBSBUPDFILE, "+>$file_471_final_out") || die ("Could not open the file in read mode"); foreach (@sbsb_upd_471){ print SBSBUPDFILE $_; } ################################################################################### #Removing the "LEOF" segments between the loops retaining it at the end of the file ################################################################################### open (SBSBUPDFILE, "<$file_471_final_out") || die ("Could not open the file in read mode"); @eof_arr = ; close (SBSBUPDFILE); for ($i = 0; $i <= $#eof_arr; $i++){ if ($eof_arr[$i] =~ /$eof/){ splice(@eof_arr,$i,1); } } push (@eof_arr,"$eof\n"); open (SBSBUPDFILE, ">$file_471_final_out") || die ("Could not open the file in write mode"); foreach (@eof_arr){ print SBSBUPDFILE $_; } close (SBSBUPDFILE); unlink $file_471_out; print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Generation of unique SBSB IDs successful\n\n"; print strftime ("%Y-%m-%d %H:%M:%S",localtime)." :: Facets 4.71 MMS KWD FILE - MMS_KWD_4.71_CONVERTED.txt with $sbsb_loop_cnt_471_act records created successfully\n"; close(SBSBUPDFILE); exit; #### Use of uninititialized value in string ne at scriptname.pl line 118, line 266 <#1>