Skip to content
Browse files

[#25060133] Update opac-downloadshelf to use Perl's "given" feature

  • Loading branch information...
1 parent 4c1129d commit 7c404e66b4c93db9de643cf5dd2574ca4a6e783f @ctfliblime ctfliblime committed Feb 20, 2012
Showing with 11 additions and 16 deletions.
  1. +7 −7 cgi/opac/opac-downloadshelf.pl
  2. +4 −9 lib/C4/Csv.pm
View
14 cgi/opac/opac-downloadshelf.pl
@@ -19,10 +19,10 @@
use strict;
use warnings;
+use feature qw(switch);
use CGI;
use Encode qw(encode);
-use Switch;
use C4::Auth;
use C4::Biblio;
@@ -67,19 +67,19 @@
push @biblios, $_->{biblionumber};
}
$output = marc2csv(\@biblios, $format);
-
+
# Other formats
} else {
foreach my $biblio (@$items) {
my $biblionumber = $biblio->{biblionumber};
my $record = GetMarcBiblio($biblionumber);
- next unless $record;
+ next unless $record;
- switch ($format) {
- case "iso2709" { $output .= $record->as_usmarc(); }
- case "ris" { $output .= marc2ris($record); }
- case "bibtex" { $output .= marc2bibtex($record, $biblionumber); }
+ given ($format) {
+ when ('iso2709') { $output .= $record->as_usmarc(); }
+ when ('ris') { $output .= marc2ris($record); }
+ when ('bibtex') { $output .= marc2bibtex($record, $biblionumber); }
}
}
}
View
13 lib/C4/Csv.pm
@@ -46,11 +46,10 @@ sub GetCsvProfiles {
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM export_format";
- $sth = $dbh->prepare($query);
+ my $sth = $dbh->prepare($query);
$sth->execute;
$sth->fetchall_arrayref({});
-
}
# Returns all informations about a given csv profile
@@ -59,7 +58,7 @@ sub GetCsvProfile {
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM export_format WHERE export_format_id=?";
- $sth = $dbh->prepare($query);
+ my $sth = $dbh->prepare($query);
$sth->execute($id);
return ($sth->fetchrow_hashref);
@@ -72,24 +71,20 @@ sub GetMarcFieldsForCsv {
my $dbh = C4::Context->dbh;
my $query = "SELECT marcfields FROM export_format WHERE export_format_id=?";
- $sth = $dbh->prepare($query);
+ my $sth = $dbh->prepare($query);
$sth->execute($id);
return ($sth->fetchrow_hashref)->{marcfields};
-
-
}
# Returns informations aboout csv profiles suitable for html templates
sub GetCsvProfilesLoop {
# List of existing profiles
my $dbh = C4::Context->dbh;
- my $sth;
my $query = "SELECT export_format_id, profile FROM export_format";
- $sth = $dbh->prepare($query);
+ my $sth = $dbh->prepare($query);
$sth->execute();
return $sth->fetchall_arrayref({});
-
}

0 comments on commit 7c404e6

Please sign in to comment.
Something went wrong with that request. Please try again.