Perl programming error

Hi, everyone!!
i am new to perl programming.. plz help me.

 
#!C:/perl/bin
use warnings;
use strict;
use Text::CSV_XS;
my @rows = "";
my $row;
my $count;
my $fh;
my @fields = "";
my $csv = Text::CSV_XS->new ({binary =>1}) or
die "cannot use CSV:" .Text::CSV->error_diag ();
open $fh,"<:encoding(utf8)","week.csv" or die "week.csv";
while($row = $csv->getline($fh))
{
if($row->[20] == "null"){
for ($count=1; $count<=13; $count++)
{
 $row->[$count] = "null";
 
 }
 }
 push @rows,$row;
 }
 
 $csv->eof or $csv->error_diag ();
 
 close $fh;
 
$csv->eol("\r\n");
 open $fh,">:encoding(utf8)", "week.csv" or die "new.csv: $!";
 $csv->print ($fh,$_) for @$row;
 
 close $fh or die "new.csv:$!";

is this above program correct?
i get a error message saying:

the line 19 is

i want to update column 21 of csv file

You dont have any value in left side of the comparison i guess.

Dump the array, and check how many value it has, and whether it has the 20th value.

Hi,
check if the variable is empty before using it:

if (defined ($row->[20]) ) {....

'==' is use to compare numerice values only. If you want to compare other than numerice, you will use the 'eq' operator. So you aviod this error you modify the below lines in your code.

if($row->[20] eq ''){

For the previous lines you dump all the records at '@rows'. But here you are using the @$row. Change the line as below

$csv->print ($fh,$_) for @rows;

You are using the same file (week.csv) input as well as output file. give another name to the output file and Change the above lines and run the program. I hope you may be got the answer.