in reply to Reading CSV Function

my @headerArray = "a,b,c,d,e,f,g,h,i,j,k"; my $headerArrayRef = \@headerArray; ... my $headingAref = "$headerArrayRef"; ... my @headerArrayCopy = @$headingAref; print ($file "@headerArrayCopy\n"); #adds header

@headerArray starts out as a single string (an array of one element).

You then assign a reference of that array to $headerArrayRef, which could have been done in one step like this:

my $headerArrayRef = [ "a,b,c,d,e,f,g,h,i,j,k" ];

Next you convert that reference to a string and assign it to $headingAref. Which means that $headingAref can never access the original data from @headerArray.

And finally you dereference a string which is an error and will not work.

for ($currentIndex >= $readLineFrom and $currentIndex <= $readLine +To){

In Perl a for (foreach) loop iterates over a list but that is a list of one value (whatever $currentIndex >= $readLineFrom and $currentIndex <= $readLineTo evaluates to).

It looks like that should be if instead of for:

if ($currentIndex >= $readLineFrom and $currentIndex <= $readLineT +o){

Or you could do it the "Perl" way:

if ( $readLineFrom .. $readLineTo ) {