Perl 代码格式化工具

专业级的 Perl 代码格式化、压缩与美化

#!/usr/bin/perl
use strict;use warnings;
=pod
This is a messy Perl script
for testing the formatter.
It contains nested blocks and mixed styles.
=cut
sub calculate_complex_stuff{my($x,$y)=@_;my $result=0;
if($x>$y){
$result=$x-$y; # This is a subtraction
print"Result is { $result }!\n";}else{
foreach my $i (1..5){$result+=$i;
if($i%2==0){print"Even number: $i\n";}
}
}return $result;}
my $val=calculate_complex_stuff(10,5);
my%test_hash=(
'key1'=>'value1','key2'=>'value2'
);
while(my($k,$v)=each%test_hash){print"Key: $k, Value: $v\n";}