Perl风格:在简短代码中使用$_
与初学者的看法相反,
$_
可以提高可读性。比较while ($line = <>) { next if $line =~ /^#/; $line =~ s/left/right/g; $line =~ tr/A-Z/a-z/; print "$ARGV:"; print $line; }
与
while ( <> ) { next if /^#/; s/left/right/g; tr/A-Z/a-z/; print "$ARGV:"; print; }
转到 使用foreach()循环
返回 使用记录的散列而不是并行数组
回到 索引
版权 © 1998,Tom Christiansen 所有权利保留。
标签
反馈
这篇文章有什么问题吗?请在GitHub上打开一个issue或pull request来帮助我们 GitHub
LATEST COMMUNITY ARTICLES
- More commenting... maybe?
github.polettix.it - Perl Weekly Challenge 121: Invert Bit
blogs.perl.org - Web nostalgia: MojoX::Mechanize
github.polettix.it - On the eve of CPAN Testers
blogs.perl.org - PWC121 - The Travelling Salesman
github.polettix.it - PWC121 - Invert Bit
github.polettix.it - Floyd-Warshall algorithm implementations
github.polettix.it - Perl Weekly Challenge 120: Swap Odd/Even Bits and Clock Angle
blogs.perl.org - How I Uploaded a CPAN Module
blogs.perl.org - App::Easer released on CPAN
github.polettix.it