#!/usr/bin/env perl
# Hulot converter: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet→text/csv
# © Reuben Thomas 2014-2015

use strict;
use warnings;

use File::Basename;
use File::Temp qw(tempdir);

use Perl6::Slurp;

my ($file, $fileext, $filebase) = @ARGV;
my $tempdir = tempdir(CLEANUP => 1);
system "soffice -env:UserInstallation=file:///`xdg-config-dir`/libreoffice-headless --headless --convert-to csv --outdir $tempdir \"$file\" > $tempdir/log";
#print STDERR scalar(slurp "$tempdir/log"); # useful for debugging
print scalar(slurp '<:raw', "$tempdir/" . basename($filebase) . ".csv");
