That will work fine -- although it's a little prettier to say open my $fh, '>>', $file; instead of doing it in two lines.
When a lexical filehandle is garbage-collected (at the end of its scope) it will automatically be closed. So if you want, you can omit the close statement. On the other hand, explicit code never hurt anyone. :)
In reply to Re: using lexically scoped variable as a filehandle
by friedo
in thread using lexically scoped variable as a filehandle
by varian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |