diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-12-28 15:56:23 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-12-28 15:56:23 +0100 |
commit | a1a881bde53bc5eddcd7be4c52a9ce8053ca9c53 (patch) | |
tree | 75d4ac86cbbf62dafe22761962eb1dd245c77dab /lib/App/Dthumb/Data.pm.PL | |
parent | c2ccc508bdccc10febd1c0cc4b12d73a757aae72 (diff) |
code cleanup
Diffstat (limited to 'lib/App/Dthumb/Data.pm.PL')
-rw-r--r-- | lib/App/Dthumb/Data.pm.PL | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/App/Dthumb/Data.pm.PL b/lib/App/Dthumb/Data.pm.PL index 32ba162..ca435bf 100644 --- a/lib/App/Dthumb/Data.pm.PL +++ b/lib/App/Dthumb/Data.pm.PL @@ -2,12 +2,13 @@ use strict; use warnings; use 5.010; -use File::Slurp qw(read_dir); +use Carp qw(carp croak); +use File::Slurp qw(read_dir read_file); use MIME::Base64 qw(encode_base64); my ($out_file) = @ARGV; -open( my $out_fh, '>', $out_file ); +open( my $out_fh, '>', $out_file ) or croak("Cannot open ${out_file}: $!"); print {$out_fh} <DATA>; @@ -22,9 +23,7 @@ for my $file ( next; } - open( my $fh, '<', $file ); - my $content = do { local $/ = undef; <$fh> }; - close($fh); + my $content = read_file($file); if ( $file =~ qr{ [.] (png | gif) $ }ox ) { $content = encode_base64($content); @@ -34,7 +33,7 @@ for my $file ( printf {$out_fh} ( "______[ %s ]______\n%s\n", $file, $content, ); } -close($out_fh); +close($out_fh) or carp("Cannot close ${out_file}: $!"); __DATA__ package App::Dthumb::Data; |