Scott Wiersdorf Updated: Mon Mar 1 10:21:28 MST 2004 Some Perl One-liners The utility of a system is directly related to its ability to accomplish useful things economically. ## summing numeric text columns ls -l | perl -lane '$sum += $F[4];' -e 'END{ print $sum; }' ## reading a URL hex encoded file perl -F'%' -lane 'print map { chr(hex($_)) } @F' < hex_file where hex_file looks like this: %3C%53%43%52%49%50%54%20%4C%41%4E%47%55%41%47%45%3D%22%4A%61%76%61%73%63 %72%69%70%74%22%3E%0A%64%6F%63%75%6D%65%6E%74%2E%6F%6E%63%6F%6E%74%65%78 %74%6D%65%6E%75%20%3D%20%64%69%73%61%62%6C%65%52%69%67%68%74%43%6C%69%63 %6B%3B%0A%66%75%6E%63%74%69%6F%6E%20%64%69%73%61%62%6C%65%52%69%67%68%74 %43%6C%69%63%6B%28%29%0A%7B%0A%20%72%65%74%75%72%6E%20%66%61%6C%73%65%3B %0A%7D%0A%76%61%72%20%6D%65%73%73%61%67%65%3D%22%22%0A%66%75%6E%63%74%69 %6F%6E%20%63%6C%69%63%6B%28%65%29%0A%7B%0A%69%66%20%28%6E%61%76%69%67%61 %74%6F%72%2E%61%70%70%4E%61%6D%65%20