$requestid = 0 unless $requestid; $enddate = "none" unless $enddate; $state = "none" unless $state; if ($update) { local $^I = ".bak"; # in place editing with backup file @ARGV = qw(/test/info.dat); while (<>) { chomp; my @array = split /,/,$_; if ($array[0] eq $requestid) { if ($enddate) { s/$array[9]/$enddate/g ;} if ($state) { s/$array[10]/$state/g ;} print; print "\n" ; } else { print join(",",@array); print "\n"; } } }