I am having a strange problem in perl that I cannot find the answer to.
I have a small script that will analyze data from an external sorce (be it a file, a website, etc.). After analyzing the data, it will save it in a CSV file. However, the problem is that when I write a file or print to display the data, it seems to truncate the beginning of the line. I use strict warnings and I don't see any errors.
Here is an example:
print "Name: " . $name . "\n"; print "Type: " . $type. "\n"; print "Price: " . $price . "\n"; print "Count: " . $count . "\n";
He will return the following:
John Blue 7.99 5
If I try to do it like this:
print "$name,$type,$price,$count\n";
The result is the following:
,7.99,5
I tried the following to find out where the problem is and get the following:
print "$name\n"; print "$name,$type\n"; print "$name,$type,$price\n"; print "$name,$type,$price,$count\n";
Results:
John John,Blue ,7.99 ,7.99,5
I'm still learning perl, but I seem to be unable to find (possibly due to lack of knowledge) what causes this. I tried to debug the script, but in the price variable I did not see a special character that could cause this.