10 tips for writing perl one-liners
blog.ksplice.com
blog.ksplice.com
Now this legacy C++ and Java... hoo boy...
http://www.catonmat.net/blog/perl-one-liners-explained-part-...
#!/usr/bin/perl
my $field = shift or usage();
$field -= 1 if $field > 0;
while (<>) {
chomp;
my @f = split;
print $f[$field], "\n";
}
sub usage {
print STDERR "$0 fieldnumber\n";
exit 1;
} perl -F, -lane '$t += $F[1]; }{ print $t'
http://www.perlfoundation.org/perl5/index.cgi?eskimo_operato...`..` is called flip-flop in the context describe in the post.
Goatse operator `=()=`:
my $count_vowels =()= /[aeiou]/g;
Here's another usage for `\K`: echo '/a/b/c/def/gh' | perl -lnE'$d{$`}++while/\w\K\b/g }{$,=" ";say keys%d'
Output: /a/b/c/def/gh /a/b/c /a/b/c/def /a/b /a
http://stackoverflow.com/questions/2892126/file-fix-it-codeg...Other features: http://stackoverflow.com/questions/161872/hidden-features-of...
http://bufferfly.members.winisp.net/Perl_oneLiners.html
(I remember especially liking the one from Sial.org - a lot of good Perl content on that site, the two from Cultured Perl and the FMTYEWTK on mass edits.)