The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

dt - CLI data transformer

VERSION

This document describes version 0.001 of dt (from Perl distribution App-dt), released on 2017-05-18.

SYNOPSIS

 % dt [OPTIONS] [FILE]...

DESCRIPTION

Roughly similar to utilities like jq, jt, the App::PipeFilter suite, jsonsel, ddsel, yamlsel, this dt utility can be used to transform data structure on the CLI using Perl code. It accepts one or several files of encoded data structures in several formats (JSON, YAML, Perl), lets you specify Perl code to modify them, and spits them out again in specified format. The input data structures are put into $DATA[0], $DATA[1] and so on. The first data structure is also put in $_.

Some examples:

  • Convert JSON to YAML

     % dt books.json -o books.yaml
  • Add a field to records, output to STDOUT

     % dt -e 'my $now = time; for (@$DATA) { $_->{status} = $_->{mtime} >= $now-7*86400 ? "new" : "" }' < books.json
  • Get YAML from STDIN, output it as Perl

     % other-cmd | dt -f yaml -F perl -o data

EXIT CODES

0 on success.

255 on I/O error.

99 on command-line options or input data error.

OPTIONS

  • --overwrite

  • --default-input-format FORMAT, -f

    Set default output format. Default is json. Can also be yaml, perl.

  • --default-output-format FORMAT, -F

    Set default output format. Default is json. Can also be yaml, perl.

  • --output FILENAME, -o

    Add an output. Format will be guessed from .

    If not specified, will output all data to STDOUT.

ENVIRONMENT

DEBUG => bool

If set to true, print debugging messages.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-dt.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-dt.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-dt

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

jq

jt, App::PipeFilter, jsonsel, ddsel, yamlsel

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.