stm has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tie::File: untie file handle
by Athanasius (Archbishop) on Aug 03, 2015 at 13:22 UTC | |
|
Re: Tie::File, is untie file handle must?
by u65 (Chaplain) on Aug 04, 2015 at 13:29 UTC | |
by 1nickt (Canon) on Aug 04, 2015 at 15:25 UTC | |
by u65 (Chaplain) on Aug 04, 2015 at 23:08 UTC | |
by BrowserUk (Patriarch) on Aug 04, 2015 at 23:20 UTC | |
by 1nickt (Canon) on Aug 05, 2015 at 00:11 UTC | |
by u65 (Chaplain) on Aug 05, 2015 at 00:30 UTC | |
|