Hello,
This question is related to Tie::File module. Have opened a file and processing array functions. Then processing do while loop, here the script has to exit if conditions are met.
Is it OK to use exit to exit the script without untie the file handle ? or any better solution available? last statement is not working here. It says an error "Can't "last" outside a loop block at". Copied few lines of my code to keep simple.
tie my @in_array, 'Tie::File', $fileA, mode => O_RDWR or die $!;
my $f_cnt = scalar(@in_array);
my $retries;
do {
##have removed lines for simplicity
##
$retries++;
if ($retries > 3) { print "3 attempts are failed.\n"; exit(); }
} while ($f_cnt > 1 );
untie @in_array;