TPJ One-Liner #3Using Perl from EmacsTo apply a Perl expression EXPR to a region:
C-u M-| perl -pe 'EXPR' To apply EXPR to the entire buffer:
C-x h C-u M-| perl -pe 'EXPR' Courtesy of Mark-Jason Dominus. |
TPJ One-Liner #4Preserving case in a substitutionTo replace substring $x with an equal length substring $y, but preserving the case of $x:Z
$string =~ s/($x)/"\L$y"^"\L$1"^$1/ie; Courtesy of Dean Inada. |
TPJ One-Liner #5Exploiting the F00F Pentium bugrequire DynaLoader; DynaLoader::dl_install_xsub("main::hangme", unpack("I", pack("P4", "\xF0\x0F\xC7\xC8"))); hangme(); Do NOT execute this. It will crash your computer. Courtesy of Gisle Aas. |
TPJ One-Liner #6Primalityperl -le 'print "PRIME" if (1 x shift) !~ /^(11+)\1+$/' 19 Type this from your command line to test whether 19 (or any other integer of your choosing) is prime. Courtesy of Abigail, abigail@fnx.com. |