in reply to Tie::File, is untie file handle must?

Hello stm,

last statement is not working here. It says an error "Can't "last" outside a loop block at".

That’s because the do { ... } while (...); construct isn’t a “real” loop; it’s a do operator followed by a while modifier. See perlsyn#Statement-Modifiers. You can re-cast your loop as follows:

{ do { ... if ($retries > 3) { print "3 attempts are failed.\n"; last; } } while ($f_cnt > 1); }

Update 1: Originally I had a LOOP: label on the outer block, and last LOOP; inside the if block; but a simple last; works just as well, and the label isn’t needed.

Alternatively, you could just add another untie @in_array statement immediately before the call to exit.

Update 2: Yet another option is to put the untie statement in an END { ... } block. The contents of any END block(s) will be executed when the script terminates, even if the termination is produced by a call to exit or die.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,