I am working on appending a file extension while looping over an array. The expected output is ABC001.csv for example but the output looks more like .csv01.
Any help on how to do this is greatly appreciated. I can provide more code if necessary.
foreach my $name (@source){
print "${name}.csv\n";
}
I am certain that you have carriage returns at the end of your file names. That is,
$nameis being set to “ABC001\r”. When you print “$name.csv\n”, you are getting:which looks like
.csv01on your screen.A quick fix would be to remove the carriage return like this:
but a better solution would be to remove the carriage returns at the point where the data comes into your application.