Every time you use the input operator (
<>), you read a new line. You can read it into a variable, but you're not doing that, so it goes directly into the special variable
$_. You read a line in the
while condition, and then clobber it by reading the next line from the file in the
split operation.
Do this instead:
while (my $line = <>) {
@chunks = split(/","/, $line);
# other stuff
}
Or use
Text::CSV to split up your comma separated values, if your data has complicated stuff like commas
within your quotes.