diff --git a/perl/exit_strategy.pl b/perl/exit_strategy.pl index 0223437fe9908196b4c50b91aa3dcef9cbeaba5e..49c4082893d220b1f8b22ac48d9416644af1e05a 100644 --- a/perl/exit_strategy.pl +++ b/perl/exit_strategy.pl @@ -47,7 +47,7 @@ use File::Basename qw(basename dirname); use File::Find; use Getopt::Long; use IO::Handle; -use List::Util qw(first); +use List::Util qw(first zip); use Path::Tiny; use Pod::Usage; use Time::Progress; @@ -689,21 +689,11 @@ sub parse_iexml($filename, $recovery_flag) { my $filegrp = $xp->findnodes("mets:fileGrp[\@ADMID='$repid']", $filesec)->[0]; $ret->{"filepids"} = get_filepids_ref($xp, $filegrp); $ret->{"files"} = get_files_ref($xp, $filegrp); - my @loc_and_size = map { - my $fpid = $_; - my $location = get_file_path($xp, $filegrp, $fpid); - #my $location = get_file_path_rx($slurp, $fpid); - #say "location=$location"; - my $size = get_filesize($xp, $fpid); - #my $size = get_filesize_rx($slurp, $fpid); - #say "size=$size"; - [ $location, $size ]; - } @{$ret->{"filepids"}}; - - foreach my $entry (@loc_and_size) { - my ($location, $size) = @{$entry}; - $ret->{"sizes"}->{$location} = $size; - } + my @locations = map {get_file_path($xp, $filegrp, $_)} @{$ret->{"filepids"}}; + my @sizes = map {get_filesize($xp, $_)} @{$ret->{"filepids"}}; + my %ls = map { $_->[0] => $_->[1] } zip \@locations, \@sizes; + $ret->{"sizes"} = \%ls; + #use Data::Printer; p($ret); return $ret; }