This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor the error handling logic in Storable::_store().
authorNicholas Clark <nick@ccl4.org>
Mon, 1 Nov 2010 07:47:50 +0000 (07:47 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 1 Nov 2010 07:47:50 +0000 (07:47 +0000)
commit9c09e8a776ed0d07848cea533d48c644a74b4890
tree0717de08d851220c0a34e4c4a196d183d0684307
parent4340b38686b9aea905708f35526360d0eff2c491
Refactor the error handling logic in Storable::_store().

The logic remains:

1: If the close fails, set $ret to undef, and attempt to unlink the file
2: If the eval set $@, attempt to unlink the file
3: If the unlink is attempted and fails, warn

However, the new code avoids using low-precedence or and a statement modifier,
both for flow control, in the same statement, which I certainly found confusing.
It also now avoids the implicit *three*-state logic for $ret, which previously
was attaching distinct meanings to true, false and undefined.

The new code has (some) flow control inside an if(), and enters a block (which
it seems that the old code strove hard to avoid - blocks are a small runtime
cost). However the block entry is only for the error case, so this should not
matter.
dist/Storable/Storable.pm