I'd say they do equivalent things. When a file handle has goes out of scope (or has no more references to it), it is automatically closed. undefing it will drop its refcount to zero, which is why it automatically closes.
I believe you would see the same behavior if you had done a simple open my $fh, "r".
At any rate, they aren't identical, but the outcome is the same. I would recommend using close, but only because I think its intent is more clear.
In reply to Re: FileHandle: undef vs close
by lostjimmy
in thread FileHandle: undef vs close
by vinoth.ree
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |