This is going to seem extremely trivial, but it just doesn’t make any sense to me.
I have the following snippit of code:
foreach $i (@inputtext)
{
@line = split(/\|/, $i);
foreach $j (@line)
{
print "$j, ";
}
}
The input is three of the following lines, identical:
98465895|No idea what goes here|123 anywhere lane|city|ST|55555|data1|pass1|data2|pass2|data3|pass3|more stuff
The output ends up being this though:
98465895, No idea what goes here, 123 anywhere lane, city, ST, 55555, data1, pass1, data2, pass2, data3, pass3, more stuff
, 98465895, No idea what goes here, 123 anywhere lane, city, ST, 55555, data1, pass1, data2, pass2, data3, pass3, more stuff
, 98465895, No idea what goes here, 123 anywhere lane, city, ST, 55555, data1, pass1, data2, pass2, data3, pass3, more stuff
There is no logical reason I can see that would create an endline inside a print statement, throwing the comma onto the next line, and messing up the next lines of the output. Anyone have any suggestions?
Thanks
We can’t see what’s reading from the file. Are you calling
chompon your input text to get rid of the trailing newline?Also, instead of doing that
forloop to join the fields with commas, do this: