Apart from the style, why do you have an else block after return. I understand that you want to give an example of the style you require, but there is more than style: there should *NEVER* be an else after return, exit or die. These three exit the surrounding scope immediately, so the code *after* else is never executed. Retaining your style, that code should read:
sub old_code { my $self = shift; my $file = shift; if (-e $file) { open(my $fh, "<", $file) or die "cannot open < $file: $!"; # Do something with the file return 1; } die "$file not found"; };
Which I would simplify to
sub old_code { my $self = shift; my $file = shift; -e $file or die "$file not found"; open(my $fh, "<", $file) or die "cannot open < $file: $!"; # Do something with the file return 1; }
In reply to Re: perltidy block indentation
by Tux
in thread perltidy block indentation
by saltbreez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |