The one-liner should:
- solve a real-world problem
- not be extensively cryptic (should be easy to understand and reproduce)
- be worth the time it takes to write it (should not be too clever)
I’m looking for practical tips and tricks (complementary examples for perldoc perlrun).
All one-liners from the answers collected in one place:
perl -pe's/([\d.]+)/localtime $1/e;' access.logack $(ls t/lib/TestPM/|awk -F'.' '{print $1}'|xargs perl -e 'print join '|' => @ARGV') aggtests/ t -lperl -e'while(<*.avi>) { s/avi$/srt/; rename <*.srt>, $_ }'find . -name '*.whatever' | perl -lne unlinktail -F /var/log/squid/access.log | perl -ane 'BEGIN{$|++} $F[6] =~ m{\Qrad.live.com/ADSAdClient31.dll} && printf '%02d:%02d:%02d %15s %9d\n', sub{reverse @_[0..2]}->(localtime $F[0]), @F[2,4]'export PATH=$(perl -F: -ane'print join q/:/, grep { !$c{$_}++ } @F'<<<$PATH)alias e2d='perl -le \'print scalar(localtime($ARGV[0]));\''perl -ple '$_=eval'perl -00 -ne 'print sort split /^/'perl -pe'1while+s/\t/' 'x(8-pos()%8)/e'tail -f log | perl -ne '$s=time() unless $s; $n=time(); $d=$n-$s; if ($d>=2) { print qq ($. lines in last $d secs, rate ),$./$d,qq(\n); $. =0; $s=$n; }'perl -MFile::Spec -e 'print join(qq(\n),File::Spec->path).qq(\n)'See corresponding answers for their descriptions.