use 5.18.2;
use warnings;
use Data::Peek;
use Text::CSV_XS qw(csv);
my $file = "pm-1192516.csv";
sub make_list {
my %opt = @_;
my %plus;
my @head = map { s/\+$// && $plus{$_}++; $_ } @{$opt{headings}};
my %foo;
my $list = csv (
in => $opt{file},
headers => \@head,
sep_char => "|",
quote_char => undef,
empty_is_undef => 1,
allow_whitespace => 1,
auto_diag => 1,
on_in => sub {
foreach my $f (@head) {
$f eq "item" and next;
push @{$foo{$_{item}}{$f}}, $plus{$f} ? split m/;\s*/
+=> $_{$f} : $_{$f};
}
},
);
return \%foo;
}
DDumper make_list (file => $file, headings => [ "item", "seen in+" ]);
->
{ 'Ark of the Covenant' => {
'seen in' => [
'Raides of the Lost Ark',
'The Librarian: Quest for the Spear'
]
},
'Book or Key of Soloman' => {
'seen in' => [
'The Librarian: Return to King Soloman\'s Mines',
'Season of the Witch'
]
},
'Crystal Skull' => {
'seen in' => [
'Stargate SG-1, Crystal Skull',
'The Librarian: Return to King Soloman\'s Mines',
'Indiana Jones and the Kingdom of the Crystal Skull'
]
},
'Doc Brown\'s Delorean' => {
'seen in' => [
'Back to the Future',
'Back to the Future Part II',
'Back to the Future Part III',
'The Librarians, And the Final Curtain'
]
},
Excalibur => {
'seen in' => [
'Excalibur',
'The Last Legion',
'The Librarian: Quest for the Spear'
]
},
'H.G. Wells\' Time Machine' => {
'seen in' => [
'The Librarians',
'Warehouse 13'
]
},
'Holy Grail' => {
'seen in' => [
'Indiana Jones and the Last Crusade',
'The Librarian: Quest for the Spear'
]
},
Necronomicon => {
'seen in' => [
'H.P. Lovecraft'
]
},
'Pandora\'s Box' => {
'seen in' => [
'Warehouse 13',
'The Librarian: Quest for the Spear'
]
},
'Spear of Destiny' => {
'seen in' => [
'The Librarian: Quest for the Spear',
'Hellboy',
'Constantine'
]
},
TARDIS => {
'seen in' => [
'Doctor Who',
'The Sarah Jane Adventures',
'The Librarians, And the Final Curtain'
]
}
}
Enjoy, Have FUN! H.Merijn
|