(although the weirdly-matched braces scare me a bit)Adding in -MO=Deparse:
The -p option wraps the script in a template equivalent to the following:perl -MO=Deparse -plwe "$h{$_}++ } for (sort {length($a) <=> length($b +) } keys %h) {" BEGIN { $^W = 1; } BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; ++$h{$_}; } foreach $_ (sort {length $a <=> length $b;} keys %h) { (); } continue { print $_; }
If your code happens to have a closing curly, you can do all kinds of interesting things. My favorite was Abigail-II's substitute for wc, to count lines:while (<>) { your code here } continue { print $_ }
perl -wlpe '}{*_=*.' filename
-QM
--
Quantum Mechanics: The dreams stuff is made of
In reply to Re: Re: Using -i in oneliner with postprocessing
by QM
in thread Using -i in oneliner with postprocessing
by Anomynous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |