my $ie_line = <IEF>;
my $ie_total = substr($ie_line, 12, 10);
my $ap_line = <APF>;
my $ap_total = substr($ap_line, 12, 10);
if ($ap_total & $ie_total){
my $merge_total = sprintf("%010d", $ap_total + $ie_total);
$ie_line =~ s/$ie_total/$merge_total/;
print OF $ie_line;
}
close(APF);
close(IEF);
close(TF);
close(OF);
and getting the following warning:
Argument "c c c c c " isn't numeric in addition (+) at ./merge_eod.pl line 29, <APF> line 1.
Argument "a a a a a " isn't numeric in addition (+) at ./merge_eod.pl line 29, <APF> line 1.
I assume that the contents you are reading from the file isn't numeric (hence the error). When you are concatenating two strings you should use a dot . to do that.
the %010d will not function if you are using strings...
Maybe I'm missing something, what is exactly the contents of $ap_total and $ie_total.
what I assume is that:
$ap_total="1 1 1 1 1" and
$ie_total="3 3 3 3 3"
containing spaces (and therefore not numeric).
if you want to assign the string "1 1 1 1 1 3 3 3 3 3" to merge_total you should:
my $merge_total = sprintf("%s", $ap_total . $ie_total) which has the same effect as:
my $merge_total = $ap_total . $ie_total;
but if you want to add ie_total to ap_total, than you should first get rid of the spaces in the strings $ap_total and $ie_total , and than add them to each other..
at least that's what I think, if I'm totally wrong let me know what you want to assign to $merge_total..