lib/Imager.pm
changeset 74 a8495233e04c
parent 72 2a7ab8422dd6
child 78 603b47708d37
equal deleted inserted replaced
73:0315e75a049d 74:a8495233e04c
     3 use strict;
     3 use strict;
     4 use warnings;
     4 use warnings;
     5 use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
     5 use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
     6 use autodie qw(:all);
     6 use autodie qw(:all);
     7 
     7 
       
     8 our $VERSION = "0.1";
       
     9 
     8 use constant CIPHER => "aes-128-cbc";
    10 use constant CIPHER => "aes-128-cbc";
       
    11 
       
    12 sub get_file {
       
    13     my ($base) = @_;
       
    14     foreach (map { "$base$_" } "", qw/.gz .x .gz.x/) {
       
    15 	return $_ if -f;
       
    16     }
       
    17 }
     9 
    18 
    10 sub get_block {
    19 sub get_block {
    11     my ($file, $buffer) = @_;
    20     my ($file, $buffer) = @_;
       
    21 
       
    22     $file = get_file($1) if $file =~ /(.*)\*$/;
    12 
    23 
    13     given ($file) {
    24     given ($file) {
    14         when (/\.gz\.x$/) {
    25         when (/\.gz\.x$/) {
    15             open(my $fh => "openssl @{[CIPHER]} -d -pass $::o{pass} -in $file|");
    26             open(my $fh => "openssl @{[CIPHER]} -d -pass $::o{pass} -in $file|");
    16             local $/ = undef;
    27             local $/ = undef;