in reply to Re: One-liner to append text at fixed column
in thread One-liner to append text at fixed column
perl -lpe " /(match1|match2)/ and $_ = sprintf qq{%-68s #$1}, $_ "
Normally I don't like short-circuit expressions, but in this case it really helps clarifying what's happening.
Demo: (win quoting)
>perl -E"say '.' x rand(80) for 1..10" |perl -lpe " /(.)/ and $_ = spr +intf qq{%-68s #$1},$_ " ...................................................................... +...... #. ...................... +#. ..................... +#. ...................................................................... +.... #. ......................................................... +#. ...................................... +#. ......................... +#. ........................................................ +#. ...................................................................... +... #. ......................... +#.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: One-liner to append text at fixed column
by Veltro (Hermit) on Nov 16, 2018 at 15:31 UTC | |
by LanX (Saint) on Nov 16, 2018 at 15:55 UTC |