2 ms·
pz versus Perl: $ echo -e "example\nwikipedia" | pz 's += ".com"' $ echo -e "example\nwikipedia" | perl -lpe '$_.=".com"' $ echo "hello world" | pz s[
by throwaway984393 5y ago
pz versus Perl:
$ echo -e "example\nwikipedia" | pz 's += ".com"'
$ echo -e "example\nwikipedia" | perl -lpe '$_.=".com"'
$ echo "hello world" | pz s[6:]
$ echo "hello world" | perl -pe '$_=substr($_,6)'
$ echo "hello world" | perl -pe 'substr($_,0,6)=""'
$ echo "hello world" | perl -lape '$_=$F[1]'
$ tail -f /var/log/syslog | pz -f '{len(s)}: {s}'
$ tail -f /var/log/syslog | perl -lpe '$_=length($_).": $_"'
$ echo "HELLO" | pz s.lower
$ echo "HELLO" | perl -pe '$_=lc'
$ echo "hello,5" | pz 's.split(",")[1]' | pz n+7
$ echo "hello,5" | perl -F, -lpe '$_=$F[1]+7'
$ pz --findall "(https?://[^\s]+)" < file.log
$ perl -lne 'print $1 if m{(https?://\S+)}' foo2.log
$ echo -e "1\n2\n3\n4" | pz --end sum
$ echo -e "1\n2\n3\n4" | perl -lne 'END{print $t} $t+=$_'
$ echo -e "1\n2\n2\n1\n3" | pz --end "sorted(set(lines))"
$ echo -e "1\n2\n2\n1\n3" | perl -ne 'END{print sort keys %h} $h{$_}++'
$ echo -e "red green\nblue red green" | pz 'C.update(s.split())' --end C.most_common
$ echo -e "red green\nblue red green" | perl -lae 'END{print "$_, $h{$_}" for sort keys %h} $h{$_}++ for @F'
- randoglando 5y agoFor people familiar with python, the first one is immediately understandable, and the second one is incomprehensible. Learning Perl may have been a better choice long-term, but this might be a good stop-gap fix for those who know Python already.