From 5e1b9bcfc0d271a8ab78f45633bb0b83b01a97ab Mon Sep 17 00:00:00 2001 From: Martin Warin Date: Thu, 19 Sep 2024 14:57:20 -0400 Subject: [PATCH] re-tidied _add_struct_map, in which i had introduced a syntax error --- lib/HTFeed/METS.pm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/HTFeed/METS.pm b/lib/HTFeed/METS.pm index e1a98639..d9f33757 100644 --- a/lib/HTFeed/METS.pm +++ b/lib/HTFeed/METS.pm @@ -829,21 +829,20 @@ sub _add_struct_map { my $mets = $self->{mets}; my $volume = $self->{volume}; my $get_pagedata = $self->{pagedata}; - my $struct_map = new METS::StructMap( - id => 'SM1', - type => 'physical' - ); + my $struct_map = new METS::StructMap(id => 'SM1', type => 'physical'); my $voldiv = new METS::StructMap::Div(type => 'volume'); $struct_map->add_div($voldiv); my $order = 1; my $file_groups_by_page = $volume->get_structmap_file_groups_by_page(); - foreach my $seqnum (sort(keys(%$file_groups_by_page))) { + + foreach my $seqnum (sort keys %$file_groups_by_page) { my $pagefiles = $file_groups_by_page->{$seqnum}; my $pagediv_ids = []; my $pagedata; my @pagedata; - while (my ($filegroup_name, $files) = each(%$pagefiles)) { + + while (my ($filegroup_name, $files) = each %$pagefiles) { foreach my $file (@$files) { my $fileid = $self->{filegroups}{$filegroup_name}->get_file_id($file); if (not defined $fileid) { @@ -864,9 +863,9 @@ sub _add_struct_map { @pagedata = %$pagedata if defined $pagedata; } else { my $other_pagedata = &$get_pagedata($file); - while (my ($key, $val) = each(%$pagedata)) { + while (my ($key, $val) = each %$pagedata) { my $val1 = $other_pagedata->{$key}; - unless ( not defined $val and not defined $val1 ) or ( $val eq $val1 ) { + unless ( (not defined $val and not defined $val1) or ($val eq $val1) ) { $self->set_error( "NotEqualValues", actual => "other=$val ,$fileid=$val1", @@ -876,9 +875,11 @@ sub _add_struct_map { } } } + push(@$pagediv_ids, $fileid); } } + $voldiv->add_file_div( $pagediv_ids, order => $order++, @@ -891,12 +892,11 @@ sub _add_struct_map { sub _save_mets { my $self = shift; - my $mets = $self->{mets}; + my $mets = $self->{mets}; my $mets_path = $self->{outfile}; - open( my $metsxml, ">", "$mets_path" ) - or die("Can't open METS xml $mets_path for writing: $!"); + open(my $metsxml, ">", "$mets_path") or die("Can't open METS xml $mets_path for writing: $!"); print $metsxml $mets->to_node()->toString(1); close($metsxml); }