in reply to Updating file name

Use the string concatenation operator
$FileName= $File . $j . ".dat";
or use interpolation
$FileName= "$File$j.dat";

By the way,
for (my $j=1;$j<=2;$j++)
is not nearly as readable as
for my $j (1..2)