Skip to content

Instantly share code, notes, and snippets.

@andrewsolomon
Created May 21, 2017 21:28
Show Gist options
  • Save andrewsolomon/6a2053b441d54a4ccff4a02b99d808cf to your computer and use it in GitHub Desktop.
Save andrewsolomon/6a2053b441d54a4ccff4a02b99d808cf to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dump 'pp';
use feature 'say';
sub isbn_catalog {
my $ra_catalog = shift;
my %isbn_catalog;
foreach my $ra_row (@$ra_catalog) {
my @row = @$ra_row;
$isbn_catalog{$row[1]} = {
publication_year => $row[0],
title => $row[2],
authors => [@row[3..$#row]],
};
}
return \%isbn_catalog;
}
my $rh_catalog = isbn_catalog([
['1998', '978-0-8001-0215-9', 'Glory', 'Freddie Fields', 'P.K. Fields', 'Pieter Jan Brugge'],
['1998', '978-0-8001-2901-9','The Whole Town\'s Talking', 'Joseph H. August','John Ford']
])
;
say pp($rh_catalog);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment