in reply to printing an array reference

You could also use Data::Dumper to print the contents of the array ref.
print Dumper(@fieldNames);