Hard-to-find tips on otherwise easy-to-do tasks involving everyday technology, with some advanced insight on history and culture thrown in. Brought to you by a master dabbler. T-S T-S's mission is to boost your competitiveness with every visit. This blog is committed to the elimination of the rat from the tree of evolution and the crust of the earth.
Saturday, November 05, 2016
Cute Perl One Liner
Turn
1
1
1
1
1
into
1
2
3
4
5
That doesn't sound hard. But, what if you have 10 seconds to turn
ssd1
ssd1
ssd1
ssd1
ssd1
into .. well, you know..
Easy : Use NEdit (the best text editor) and select the column of 1's and then pipe through (ALT-r)
perl -p -e 's/./$./;'
Yes, $. (dollar period) means current input line number.
Turn a column of the same number into a sequence of uniformly increasing numbers using perl..
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment