Perl单行应用详解
2014-03-06 11:39:52

Useful One-Line Scripts for Perl   Jan 28 2012 | version 1.08
--------------------------------   -----------   ------------

Perl有很多命令行参数,通过它可让程序更简练,并且可以写出很多只有一行命令的perl。本文就是这个目的,通过单行的应用可以把perl的最好的一面表现的更加优秀,在很多地方它是可以取代shell指令的。文章是翻译过来的,专门介绍perl命令行下各种应用;原作者的心意更大,要将此类的应用写成一本书(下文有链接)。在前文中,也有此类的文章:Perl命令行应用介绍

Compiled by Peteris Krumins (peter@catonmat.net, @pkrumins on Twitter)(本文原文的出处)
http://www.catonmat.net -- good coders code, great reuse

Latest version of this file is always at:
可以从此取得最新版本。
http://www.catonmat.net/download/perl1line.txt

This file is also available in other languages:
如果你愿意将其译成其它语种的,请电邮我。
Please email me peter@catonmat.net if you wish to translate it.

Perl One-Liners on Github:
也能在Github找到本文。
https://github.com/pkrumins/perl1line.txt

I have also written "Perl One-Liners Explained" ebook that's based on this file. It explains all the one-liners here. Get it at:
我从这篇文章写了一本书:Perl单行应用详解(这个名字是译者取的,不要见怪),可以通过下面地址取得详情。
http://www.catonmat.net/blog/perl-book/

These one-liners work both on UNIX systems and Windows. Most likely your UNIX system already has Perl. For Windows get the Strawberry Perl at:
本书中的内容可以在unix及windows下运行,unix下已经存在perl,而windows下可以使用Strawberry Perl,下面是其链接。
http://www.strawberryperl.com/

Table of contents:
1. File Spacing
2. Line Numbering
3. Calculations
4. String Creation and Array Creation
5. Text Conversion and Substitution
6. Selective Printing and Deleting of Certain Lines    
7. Handy Regular Expressions
8. Perl tricks

FILE SPACING(空格处理)

------------

# Double space a file
perl -pe '$\="\n"'
perl -pe 'BEGIN { $\="\n" }'
perl -pe '$_ .= "\n"'
perl -pe 's/$/\n/'

# Double space a file, except the blank lines
perl -pe '$_ .= "\n" unless /^$/'
perl -pe '$_ .= "\n" if /\S/'

# Triple space a file
perl -pe '$\="\n\n"'
perl -pe '$_.="\n\n"'

# N-space a file
perl -pe '$_.="\n"x7'

# Add a blank line before every line
perl -pe 's//\n/'

# Remove all blank lines
perl -ne 'print unless /^$/'
perl -lne 'print if length'
perl -ne 'print if /\S/'

#Remove all consecutive blank lines, leaving just one
#移除所有的连续空行,仅留下一行
perl -00 -pe ''
perl -00pe0

#Compress/expand all blank lines into N consecutive ones
#减少或增加若干空行到每一段
perl -00 -pe '$_.="\n"x4'

#Fold a file so that every set of 10 lines becomes one tab-separated line
#每10行加入一个Tab符
perl -lpe '$\ = $.%10 ? "\t" : "\n"'


LINE NUMBERING(行号处理)
--------------

#Number all lines in a file
#在每一行前加上行号
perl -pe '$_ = "$. $_"'

#Number only non-empty lines in a file
#为非空添加行号
perl -pe '$_ = ++$a." $_" if /./'

#Number and print only non-empty lines in a file (drop empty lines)
#移除空行并为之添加行号
perl -ne 'print ++$a." $_" if /./'

#Number all lines but print line numbers only non-empty lines
#输出所有行,但仅为非空行打出行号(计数也同步)
perl -pe '$_ = "$. $_" if /./'

#Number only lines that match a pattern, print others unmodified
#匹配查找,并在输出行上加上行号
perl -pe '$_ = ++$a." $_" if /regex/'

#Number and print only lines that match a pattern
#匹配查找,仅输出匹配行上加上行号
perl -ne 'print ++$a." $_" if /regex/'

#Number all lines, but print line numbers only for lines that match a pattern
#匹配查找,输出行上并附上行号
perl -pe '$_ = "$. $_" if /regex/'

#Number all lines in a file using a custom format (emulate cat -n)
#使用自定义格式输出,前置行号
perl -ne 'printf "%-5d %s", $., $_'

#Print the total number of lines in a file (emulate wc -l)
#统计文件的行数
perl -lne 'END { print $. }'
perl -le 'print $n=()=<>'
perl -le 'print scalar(()=<>)'
perl -le 'print scalar(@foo=<>)'
perl -ne '}{print $.'
perl -nE '}{say $.'

#Print the number of non-empty lines in a file
#统计文件中非空行
perl -le 'print scalar(grep{/./}<>)'
perl -le 'print ~~grep{/./}<>'
perl -le 'print~~grep/./,<>'
perl -E 'say~~grep/./,<>'

#Print the number of empty lines in a file
#统计文件在空行数
perl -lne '$a++ if /^$/; END {print $a+0}'
perl -le 'print scalar(grep{/^$/}<>)'
perl -le 'print ~~grep{/^$/}<>'
perl -E 'say~~grep{/^$/}<>'

#Print the number of lines in a file that match a pattern (emulate grep -c)
#统计文件某词出现的次数
perl -lne '$a++ if /regex/; END {print $a+0}'
perl -nE '$a++ if /regex/; END {say $a+0}'


CALCULATIONS(运算)
------------

#Check if a number is a prime
#
perl -lne '(1x$_) !~ /^1?$|^(11+?)\1+$/ && print "$_ is prime"'

#Print the sum of all the fields on a line
#计算文件中每行各列的和
perl -MList::Util=sum -alne 'print sum @F'

#Print the sum of all the fields on all lines
#计算每行每列的和,汇总后输出
perl -MList::Util=sum -alne 'push @S,@F; END { print sum @S }'
perl -MList::Util=sum -alne '$s += sum @F; END { print $s }'

#Shuffle all fields on a line
#将每行各列按随机排列后输出
perl -MList::Util=shuffle -alne 'print "@{[shuffle @F]}"'
perl -MList::Util=shuffle -alne 'print join " ", shuffle @F'

#Find the minimum element on a line
#找出每行该列中最小值
perl -MList::Util=min -alne 'print min @F'

#Find the minimum element over all the lines
#找出所有行列中的最小值
perl -MList::Util=min -alne '@M = (@M, @F); END { print min @M }'
perl -MList::Util=min -alne '$min = min @F; $rmin = $min unless defined $rmin && $min > $rmin; END { print $rmin }'

#Find the maximum element on a line
#找出每行该列中最大值
perl -MList::Util=max -alne 'print max @F'

#Find the maximum element over all the lines
#找出所有行列中的最大值
perl -MList::Util=max -alne '@M = (@M, @F); END { print max @M }'

#Replace each field with its absolute value
#将行列中的负数转正
perl -alne 'print "@{[map { abs } @F]}"'

#Find the total number of fields (words) on each line
#统计每行中出现的字数(中文目前没有办法统计)
perl -alne 'print scalar @F'

#Print the total number of fields (words) on each line followed by the line
#将每行的统计字数置于每行前
perl -alne 'print scalar @F, " $_"'

#Find the total number of fields (words) on all lines
#将文件中字数统计汇总
perl -alne '$t += @F; END { print $t}'

#Print the total number of fields that match a pattern
#统计文件中出现的关键字出现的次数
perl -alne 'map { /regex/ && $t++ } @F; END { print $t }'
perl -alne '$t += /regex/ for @F; END { print $t }'
perl -alne '$t += grep /regex/, @F; END { print $t }'

#Print the total number of lines that match a pattern
#统计文件中出现的关键字出现的次数
perl -lne '/regex/ && $t++; END { print $t }'

#Print the number PI to n decimal places
#计算pi的值
perl -Mbignum=bpi -le 'print bpi(n)'
#Print the number PI to 39 decimal places
perl -Mbignum=PI -le 'print PI'

#Print the number E to n decimal places
#计算科学计数e
perl -Mbignum=bexp -le 'print bexp(1,n+1)'

#Print the number E to 39 decimal places
perl -Mbignum=e -le 'print e'

#Print UNIX time (seconds since Jan 1, 1970, 00:00:00 UTC)
#取得unix时间戳
perl -le 'print time'

#Print GMT (Greenwich Mean Time) and local computer time
#取得本地的真实时间和gmt时间
perl -le 'print scalar gmtime'
perl -le 'print scalar localtime'

#Print local computer time in H:M:S format
#将本地时间格式化后输出
perl -le 'print join ":", (localtime)[2,1,0]'

#Print yesterday's date
#得到昨天的日期时间
perl -MPOSIX -le '@now = localtime; $now[3] -= 1; print scalar localtime mktime @now'

#Print date 14 months, 9 days and 7 seconds ago
#得到一个具体时间之前的日期
perl -MPOSIX -le '@now = localtime; $now[0] -= 7; $now[4] -= 14; $now[7] -= 9; print scalar localtime mktime @now'

#Prepend timestamps to stdout (GMT, localtime)
#将文件里的时间进行处理
tail -f logfile | perl -ne 'print scalar gmtime," ",$_'
tail -f logfile | perl -ne 'print scalar localtime," ",$_'

#Calculate factorial of 5
#计算递归数列
perl -MMath::BigInt -le 'print Math::BigInt->new(5)->bfac()'
perl -le '$f = 1; $f *= $_ for 1..5; print $f'

#Calculate greatest common divisor (GCM)
#计算最大公约数
perl -MMath::BigInt=bgcd -le 'print bgcd(@list_of_numbers)'

#Calculate GCM of numbers 20 and 35 using Euclid's algorithm
#采用欧几里德算法计算最大公约数
perl -le '$n = 20; $m = 35; ($m,$n) = ($n,$m%$n) while $n; print $m'

#Calculate least common multiple (LCM) of numbers 35, 20 and 8
perl -MMath::BigInt=blcm -le 'print blcm(35,20,8)'

#Calculate LCM of 20 and 35 using Euclid's formula: n*m/gcd(n,m)
perl -le '$a = $n = 20; $b = $m = 35; ($m,$n) = ($n,$m%$n) while $n; print $a*$b/$m'

#Generate 10 random numbers between 5 and 15 (excluding 15)
#生成多个随机数
perl -le '$n=10; $min=5; $max=15; $, = " "; print map { int(rand($max-$min))+$min } 1..$n'

#Find and print all permutations of a list
#找出并打印列表的排列
perl -MAlgorithm::Permute -le '$l = [1,2,3,4,5]; $p = Algorithm::Permute->new($l); print @r while @r = $p->next'

#Generate the power set
perl -MList::PowerSet=powerset -le '@l = (1,2,3,4,5); for (@{powerset(@l)}) { print "@$_" }'

#Convert an IP address to unsigned integer
#将ip地址转换为正整数
perl -le '$i=3; $u += ($_<<8*$i--) for "127.0.0.1" =~ /(\d+)/g; print $u'
perl -le '$ip="127.0.0.1"; $ip =~ s/(\d+)\.?/sprintf("%02x", $1)/ge; print hex($ip)'
perl -le 'print unpack("N", 127.0.0.1)'
perl -MSocket -le 'print unpack("N", inet_aton("127.0.0.1"))'

#Convert an unsigned integer to an IP address
#将正整数转换为ip地址
perl -MSocket -le 'print inet_ntoa(pack("N", 2130706433))'
perl -le '$ip = 2130706433; print join ".", map { (($ip>>8*($_))&0xFF) } reverse 0..3'
perl -le '$ip = 2130706433; $, = "."; print map { (($ip>>8*($_))&0xFF) } reverse 0..3'

STRING CREATION AND ARRAY CREATION(字串和数组)
----------------------------------

#Generate and print the alphabet
#生成字母表
perl -le 'print a..z'
perl -le 'print ("a".."z")'
perl -le '$, = ","; print ("a".."z")'
perl -le 'print join ",", ("a".."z")'

#Generate and print all the strings from "a" to "zz"
#生成所有字母表(两位)
perl -le 'print ("a".."zz")'
perl -le 'print "aa".."zz"'

#Create a hex lookup table
#十六进制字符
@hex = (0..9, "a".."f")

#Convert a decimal number to hex using @hex lookup table
#将十进制转换为十六进制
perl -le '$num = 255; @hex = (0..9, "a".."f"); while ($num) { $s = $hex[($num%16)&15].$s; $num = int $num/16 } print $s'
perl -le '$hex = sprintf("%x", 255); print $hex'
perl -le '$num = "ff"; print hex $num'

#Generate a random 8 character password
#生成8位随机密码
perl -le 'print map { ("a".."z")[rand 26] } 1..8'
perl -le 'print map { ("a".."z", 0..9)[rand 36] } 1..8'

#Create a string of specific length
#生成固定长度的字串
perl -le 'print "a"x50'

#Create a repeated list of elements
#生成重复的列表串
perl -le '@list = (1,2)x20; print "@list"'

#Create an array from a string
#将字串构造为数组
@months = split ' ', "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec"
@months = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/

#Create a string from an array
#将数组转为字串
@stuff = ("hello", 0..9, "world"); $string = join '-', @stuff

#Find the numeric values for characters in the string
#将字串中的字母转为数字
perl -le 'print join ", ", map { ord } split //, "hello world"'

#Convert a list of numeric ASCII values into a string
#将数字转为字串
perl -le '@ascii = (99, 111, 100, 105, 110, 103); print pack("C*", @ascii)'
perl -le '@ascii = (99, 111, 100, 105, 110, 103); print map { chr } @ascii'

#Generate an array with odd numbers from 1 to 100
#数组计算重组
perl -le '@odd = grep {$_ % 2 == 1} 1..100; print "@odd"'
perl -le '@odd = grep { $_ & 1 } 1..100; print "@odd"'

#Generate an array with even numbers from 1 to 100
#数组计算重组
perl -le '@even = grep {$_ % 2 == 0} 1..100; print "@even"'

#Find the length of the string
#计算字串的长度
perl -le 'print length "one-liners are great"'

#Find the number of elements in an array
#计算数组中的元素个数
perl -le '@array = ("a".."z"); print scalar @array'
perl -le '@array = ("a".."z"); print $#array + 1'


TEXT CONVERSION AND SUBSTITUTION(文本转换及替换)
--------------------------------

#ROT13 a string
#
'y/A-Za-z/N-ZA-Mn-za-m/'

#ROT 13 a file
#文件替换
perl -lpe 'y/A-Za-z/N-ZA-Mn-za-m/' file

#Base64 encode a string
#将字串进行base64编码
perl -MMIME::Base64 -e 'print encode_base64("string")'
perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' file

#Base64 decode a string
#对字串进行反base64解码
perl -MMIME::Base64 -le 'print decode_base64("base64string")'
perl -MMIME::Base64 -ne 'print decode_base64($_)' file

#URL-escape a string
#
perl -MURI::Escape -le 'print uri_escape($string)'

#URL-unescape a string
#
perl -MURI::Escape -le 'print uri_unescape($string)'

#HTML-encode a string
#
perl -MHTML::Entities -le 'print encode_entities($string)'

#HTML-decode a string
#
perl -MHTML::Entities -le 'print decode_entities($string)'

#Convert all text to uppercase
#将文本的字母转为大写
perl -nle 'print uc'
perl -ple '$_=uc'
perl -nle 'print "\U$_"'

#Convert all text to lowercase
#将文本的字母转为小写
perl -nle 'print lc'
perl -ple '$_=lc'
perl -nle 'print "\L$_"'

#Uppercase only the first word of each line
#将文本的每行首字母转为大写
perl -nle 'print ucfirst lc'
perl -nle 'print "\u\L$_"'

#Invert the letter case
#将文本的大小写转置
perl -ple 'y/A-Za-z/a-zA-Z/'

#Camel case each line
#将文本中每行进行驼峰化
perl -ple 's/(\w+)/\u$1/g'
perl -ple 's/(?<!['])(\w+)/\u\1/g'

#Strip leading whitespace (spaces, tabs) from the beginning of each line
#去行首的空白
perl -ple 's/^[ \t]+//'
perl -ple 's/^\s+//'

#Strip trailing whitespace (space, tabs) from the end of each line
#去行末的空白
perl -ple 's/[ \t]+$//'

#Strip whitespace from the beginning and end of each line
#去行首/末的空白
perl -ple 's/^[ \t]+|[ \t]+$//g'

#Convert UNIX newlines to DOS/Windows newlines
#文本由unix格式转为win32格式(换行符)
perl -pe 's|\n|\r\n|'

#Convert DOS/Windows newlines to UNIX newlines
#文本由win32格式转为unix格式(换行符)
perl -pe 's|\r\n|\n|'

#Convert UNIX newlines to Mac newlines
#文本由win32格式转为mac格式(换行符)
perl -pe 's|\n|\r|'

#Substitute (find and replace) "foo" with "bar" on each line
#对每行第一次出现地字串进行替换
perl -pe 's/foo/bar/'

#Substitute (find and replace) all "foo"s with "bar" on each line
#对每行所有出现地字串进行替换
perl -pe 's/foo/bar/g'

#Substitute (find and replace) "foo" with "bar" on lines that match "baz"
#
perl -pe '/baz/ && s/foo/bar/'

#Binary patch a file (find and replace a given array of bytes as hex numbers)
#
perl -pi -e 's/\x89\xD8\x48\x8B/\x90\x90\x48\x8B/g' file


SELECTIVE PRINTING AND DELETING OF CERTAIN LINES(选择性打印和删除某些行)
------------------------------------------------

#Print the first line of a file (emulate head -1)
#给出文件的首行
perl -ne 'print; exit'

#Print the first 10 lines of a file (emulate head -10)
#取得文件前10行
perl -ne 'print if $. <= 10'
perl -ne '$. <= 10 && print'
perl -ne 'print if 1..10'

#Print the last line of a file (emulate tail -1)
#得到文件的最后一行
perl -ne '$last = $_; END { print $last }'
perl -ne 'print if eof'

#Print the last 10 lines of a file (emulate tail -10)
#得到文件的最后10行
perl -ne 'push @a, $_; @a = @a[@a-10..$#a]; END { print @a }'

#Print only lines that match a regular expression
#得到匹配的第一行
perl -ne '/regex/ && print'

#Print only lines that do not match a regular expression
#得到非匹配的第一行
perl -ne '!/regex/ && print'

#Print the line before a line that matches a regular expression
#得到匹配行的前一行
perl -ne '/regex/ && $last && print $last; $last = $_'

#Print the line after a line that matches a regular expression
#得到匹配行的后一行
perl -ne 'if ($p) { print; $p = 0 } $p++ if /regex/'

#Print lines that match regex AAA and regex BBB in any order
#得到匹配行的行号
perl -ne '/AAA/ && /BBB/ && print'

#Print lines that don't match match regexes AAA and BBB
#得到非匹配行的行号
perl -ne '!/AAA/ && !/BBB/ && print'

#Print lines that match regex AAA followed by regex BBB followed by CCC
#
perl -ne '/AAA.*BBB.*CCC/ && print'

#Print lines that are 80 chars or longer
#得到多于80字符的行
perl -ne 'print if length($_) >= 80'

#Print lines that are less than 80 chars in length
#得到少于80字符的行
perl -ne 'print if length($_) < 80'

#Print only line 13
#得到具体行的内容
perl -ne '$. == 13 && print && exit'

#Print all lines except line 27
#得到除某一行外所有行
perl -ne '$. != 27 && print'
perl -ne 'print if $. != 27'

#Print only lines 13, 19 and 67
#仅得到具体行
perl -ne 'print if $. == 13 || $. == 19 || $. == 67'
perl -ne 'print if int($.) ~~ (13, 19, 67)'

#Print all lines between two regexes (including lines that match regex)
#得到在正则区间的所有行
perl -ne 'print if /regex1/../regex2/'

#Print all lines from line 17 to line 30
#得到某两行间的内容
perl -ne 'print if $. >= 17 && $. <= 30'
perl -ne 'print if int($.) ~~ (17..30)'
perl -ne 'print if grep { $_ == $. } 17..30'

#Print the longest line
#得到最长的行
perl -ne '$l = $_ if length($_) > length($l); END { print $l }'

#Print the shortest line
#得到最短的行
perl -ne '$s = $_ if $. == 1; $s = $_ if length($_) < length($s); END { print $s }'

#Print all lines that contain a number
#得到所有包含了数字的行
perl -ne 'print if /\d/'

#Find all lines that contain only a number
#得到所有只包含了数字的行
perl -ne 'print if /^\d+$/'

#Print all lines that contain only characters
#得到所有只包含了字母的行
perl -ne 'print if /^[[:alpha:]]+$/

#Print every second line
#得到奇数行
perl -ne 'print if $. % 2'

#Print every second line, starting the second line
#得到偶数行
perl -ne 'print if $. % 2 == 0'

#Print all lines that repeat
#得到重复的行
perl -ne 'print if ++$a{$_} == 2'

#Print all unique lines
#取得所有唯一行
perl -ne 'print unless $a{$_}++'

#Print the first field (word) of every line (emulate cut -f 1 -d ' ')
#得到文本的第一列
perl -alne 'print $F[0]'


HANDY REGULAR EXPRESSIONS(处理正则表达式)
-------------------------

#Match something that looks like an IP address
#匹配ip地址
/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
/^(\d{1,3}\.){3}\d{1,3}$/

#Test if a number is in range 0-255
#匹配数据是否在0-255内
/^([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$/

#Match an IP address
#匹配ip地址是否合法
my $ip_part = qr|([0-9]|[0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|;
if ($ip =~ /^($ip_part\.){3}$ip_part$/) {
 say "valid ip";
}

#Check if the string looks like an email address
#匹配电子邮件地址
/\S+@\S+\.\S+/

#Check if the string is a decimal number
#匹配十进制数
/^\d+$/
/^[+-]?\d+$/
/^[+-]?\d+\.?\d*$/

#Check if the string is a hexadecimal number
#匹配字串是否为十六进制
/^0x[0-9a-f]+$/i

#Check if the string is an octal number
#匹配字串是否为八进制
/^0[0-7]+$/

#Check if the string is binary
#匹配字串是否为二进制
/^[01]+$/

#Check if a word appears twice in the string
#匹配单词串是否在字串里出现了两次
/(word).*\1/

#Increase all numbers by one in the string
#将字串里出现的数字加1
$str =~ s/(\d+)/$1+1/ge

#Extract HTTP User-Agent string from the HTTP headers
#从http头中时取得浏览器信息
/^User-Agent: (.+)$/

#Match printable ASCII characters
#得到可打印字符
/[ -~]/

#Match unprintable ASCII characters
#得到不可打印字符
/[^ -~]/

#Match text between two HTML tags
#匹配html标签对
m|<strong>([^<]*)</strong>|
m|<strong>(.*?)</strong>|

#Replace all <b> tags with <strong>
#用<strong>来替换所有<b>标签
$html =~ s|<(/)?b>|<$1strong>|g

#Extract all matches from a regular expression
#从正则表达式中取的后存入数组
my @matches = $text =~ /regex/g;


PERL TRICKS(一些小技巧)
-----------

#Print the version of a Perl module
#得到模块的版本号
perl -MModule -le 'print $Module::VERSION'
perl -MLWP::UserAgent -le 'print $LWP::UserAgent::VERSION'


PERL ONE-LINERS EXPLAINED E-BOOK(perl one-line电子书)
--------------------------------

I have written an ebook based on the one-liners in this file. If you wish to support my work and learn more about these one-liners, you can get a copy of my ebook at:(我基于本文写了一本书来详解这种单行应用,希望能得到大家的支持,可以从下面链接中来下载该书的电子档)

http://www.catonmat.net/blog/perl-book/

The ebook is based on the 7-part article series that I wrote on my blog.In the ebook I reviewed all the one-liners, improved explanations, added new ones, and added two new chapters - introduction to Perl one-liners and summary of commonly used special variables.

这本电子书分为7个章节,可以从我的blog上看到,我曾修改多次,目前业已杀青。

You can read the original article series here(下面是书的原始稿件链接):

http://www.catonmat.net/blog/perl-one-liners-explained-part-one/

http://www.catonmat.net/blog/perl-one-liners-explained-part-two/

http://www.catonmat.net/blog/perl-one-liners-explained-part-three/

http://www.catonmat.net/blog/perl-one-liners-explained-part-four/

http://www.catonmat.net/blog/perl-one-liners-explained-part-five/

http://www.catonmat.net/blog/perl-one-liners-explained-part-six/

http://www.catonmat.net/blog/perl-one-liners-explained-part-seven/


CREDITS(致谢)
-------

Andy Lester       http://www.petdance.com
Shlomi Fish       http://www.shlomifish.org
Madars Virza      http://www.madars.org
caffecaldo        https://github.com/caffecaldo
Kirk Kimmel       https://github.com/kimmel
avar              https://github.com/avar

FOUND A BUG? HAVE ANOTHER ONE-LINER?(使用下面的邮件地址汇报bug)
------------------------------------

Email bugs and new one-liners to me at peter@catonmat.net!

I hope you found these one-liners useful. Have fun!

#全文结束

单行Perl应用的pdf文档,可以从附件中下载。

perl-one-liners.pdf