Variables, begin/end blocks, pattern-action blocks
This major release dramatically expands the expressive power of Miller's put
DSL. The TL;DR is that you can now write things like
mlr put '@x_sum += $x; end { emit @x_sum }'
For full details please see the following reference sections:
- http://johnkerl.org/miller/doc/reference.html#put
- http://johnkerl.org/miller/doc/reference.html#Out-of-stream_variables_for_put
- http://johnkerl.org/miller/doc/reference.html#Pattern-action_blocks_for_put
- http://johnkerl.org/miller/doc/reference.html#Begin/end_blocks_for_put
- http://johnkerl.org/miller/doc/reference.html#Indexed_out-of-stream_variables_for_put
- http://johnkerl.org/miller/doc/reference.html#Emit_statements_for_put
- http://johnkerl.org/miller/doc/reference.html#Unset_statements_for_put
as well as the following cookbook section:
Additional minor features in Miller 4.0.0:
- Compound assignment operators such as
+=
,<<=
, etc. are not new but were not previously announced in a release note. - Double-backslashing behavior for
sub
andgsub
has been fixed:echo 'x=a\tb' | mlr put '$x=sub($x,"\\t","TAB")'
now printsaTABb
as desired. (The underlying issue was an unfortunate interaction between Miller's backslash-handling and the system regex library's backslash-handling.) - As an alternative to specifying input files as the last items on the Miller command line, you can now specify a single input file before other command-line switches and verbs using
--from
: for example,mlr --from myfile.dat put '$z = $x + $y' then stats1 -a sum -f z
. The context is simple keystroke-reduction for interactively appending then-chains by up-arrowing at the command line: it's easier to iterate when you don't have to left-arrow past the input file name.