in reply to "open" Best Practices
Nice! I'd add a blurb about using close(), as well as a scoped block example (perhaps linking the two). One good example of when to use a block is using a local record separator variable (the close isn't really necessary in this case, but I digress):
my $file = 'test.txt'; my $json; { local $/; open my $fh, '<', $file or die $!; $json = <$fh>; close $fh; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: "open" Best Practices
by haukex (Bishop) on Jul 11, 2019 at 15:02 UTC |
In Section
Meditations