Perl uses a link counting strategy to collect garbage. When the number of reference variables reaches 0, any applicable method is called DESTROYbefore freeing its memory for the perl memory management system.
As your program completes, the remaining variables will go out of scope and their reference count will decrease. This is the moment when your files will be closed.
perl , , , (, init ) .
: , , , 0, DESTROY, , perl DESTROY / , .