betmatt has asked for the wisdom of the Perl Monks concerning the following question:
as compared to:with open ('test.txt', 'n') as f print(f.mode) #f.close # not required
The first case will automatically exit the file when outside the block. The second case requires instruction. Is there an equivalence for Perl? What would the merits be of a similar approach in Perl?f = open ('test.txt','n') print(f.mode) f.close() # required
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Automatically exiting a file within a block
by davido (Cardinal) on Jun 23, 2019 at 18:31 UTC | |
Re: Automatically exiting a file within a block
by stevieb (Canon) on Jun 23, 2019 at 18:26 UTC | |
by ikegami (Pope) on Jun 26, 2019 at 08:22 UTC | |
Re: Automatically exiting a file within a block
by haukex (Bishop) on Jun 23, 2019 at 19:52 UTC | |
by null recurrent (Novice) on Jun 23, 2019 at 23:39 UTC |