Skip to content

Instantly share code, notes, and snippets.

@LadyAleena
Last active July 3, 2020 13:15
Show Gist options
  • Save LadyAleena/42b04e63c764e6c6311d2d6facf8fb51 to your computer and use it in GitHub Desktop.
Save LadyAleena/42b04e63c764e6c6311d2d6facf8fb51 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Text::CSV;
use Data::Dumper;
my $csv = Text::CSV->new({
sep_char => '|',
quote_char => undef,
blank_is_undef => 1,
empty_is_undef => 1,
allow_whitespace => 1,
});
$csv->column_names('Weapon','#AT','Dmg(S/M)','Dmg(L)','Range','Weight','Size','Type','Speed','KO','broad group','tight group');
my $fn = 'site/files/data/Role_playing/Reference_tables/Weapons.txt';
open(my $fh, '<', $fn) || die "Can't open $fn. $!";
my $array = $csv->getline_hr_all($fh);
my $hash = {
map { $_->{"Weapon"} => $_ } @$array
};
print Dumper($hash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment