Getting warning in the Perl Script

Hello All,

I have written the below perl script:

#!/usr/bin/perl
use strict;
use warnings;

if ($#ARGV != 2) {
print "usage: merge_eod AP_filename IE_filename \n";
exit;
}
my($trg) = ".trg";
my($output_file) = $ARGV[2];
my($ie_file) = $ARGV[1];
my($ap_file) = $ARGV[0];
my($trg_file) = $output_file . $trg;

open(OF, ">$output_file");
open(IEF, $ie_file);
open(APF, $ap_file);
open(TF, ">$trg_file");

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.

Any help will be highly appreciated

Cheers,
Pulkit

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...

Thanks, But after using .dot operator and numeric values it is giving:

Argument "1 1 1 1 1 3 3 3 3\n" isn't numeric in sprintf at ./merge_eod.pl line 29, <APF> line 1.

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..

You will get that when you try making a %s a %d