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
In reply to Re^2: One-liner to append text at fixed column
by LanX
in thread One-liner to append text at fixed column
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |