30 lines
419 B
Perl
30 lines
419 B
Perl
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings;
|
|
use JSON;
|
|
|
|
my $n = 1;
|
|
my @headers;
|
|
my $json = [];
|
|
for my $line (<>) {
|
|
chomp($line);
|
|
my $item = {};
|
|
if ($n == 1) {
|
|
@headers = split(";", $line);
|
|
}
|
|
else {
|
|
my @items = split(";", $line);
|
|
my $i = 0;
|
|
for my $header (@headers) {
|
|
$item->{$header} = $items[$i];
|
|
$i = $i + 1;
|
|
}
|
|
push(@$json, $item);
|
|
$item = {};
|
|
}
|
|
$n = $n + 1;
|
|
}
|
|
|
|
print encode_json $json;
|