25 lines
474 B
Perl
Executable file
25 lines
474 B
Perl
Executable file
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
use warnings FATAL => 'all';
|
|
|
|
use YAML::Any;
|
|
use CSV::Writer;
|
|
use Getopt::Long;
|
|
|
|
my @columns;
|
|
|
|
GetOptions(
|
|
'columns=s@' => sub {
|
|
my ( $opt, $value ) = @_;
|
|
push @columns, split qr{\s*,\s*}, $value;
|
|
}
|
|
) and @columns > 0
|
|
or die "Usage: $0 [--columns=...]\n";
|
|
|
|
my $csv = CSV::Writer->new( columns => \@columns );
|
|
$csv->write( $csv->columns );
|
|
|
|
for my $d ( YAML::Any::LoadFile( \*STDIN ) ) {
|
|
$csv->write( $d );
|
|
}
|