diff options
author | Nicholas Clark <nick@ccl4.org> | 2008-03-17 00:17:26 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-03-17 00:17:26 +0000 |
commit | 08858ed21b9a4d448437bdae35df5c42fbe1c8bd (patch) | |
tree | d27bb2954cf830c9866eaa74e228a0a358b0d119 /regen_lib.pl | |
parent | 424a4936e3f61f4e8db394f496a116e698cede85 (diff) | |
download | perl-08858ed21b9a4d448437bdae35df5c42fbe1c8bd.tar.gz |
Drag autodoc.pl and overload.pl into the age of safer_open().
Thanks to the wisdom of london.pm, stuff the filename into the SCALAR
slot of the typeglob created in safer_open(), so that ...
Add safer_close(), that will die (with the filename) if the close
fails.
p4raw-id: //depot/perl@33539
Diffstat (limited to 'regen_lib.pl')
-rw-r--r-- | regen_lib.pl | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/regen_lib.pl b/regen_lib.pl index 824926554a..7605271ec8 100644 --- a/regen_lib.pl +++ b/regen_lib.pl @@ -57,8 +57,14 @@ sub safer_open { my $name = shift; my $fh = gensym; open $fh, ">$name" or die "Can't create $name: $!"; + *{$fh}->{SCALAR} = $name; binmode $fh; $fh; } +sub safer_close { + my $fh = shift; + close $fh or die 'Error closing ' . *{$fh}->{SCALAR} . ": $!"; +} + 1; |