in reply to perltidy block indentation
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perltidy block indentation
by dasgar (Priest) on Dec 04, 2013 at 15:07 UTC | |
by Tux (Canon) on Dec 04, 2013 at 16:55 UTC | |
|
Re^2: perltidy block indentation
by Anonymous Monk on Dec 03, 2013 at 12:42 UTC | |
by Bloodnok (Vicar) on Dec 03, 2013 at 13:44 UTC | |
by saltbreez (Novice) on Dec 03, 2013 at 14:10 UTC | |
by wollmers (Scribe) on Dec 04, 2013 at 08:46 UTC | |
|
Re^2: perltidy block indentation
by Anonymous Monk on Dec 03, 2013 at 12:14 UTC | |
by marto (Cardinal) on Dec 03, 2013 at 12:26 UTC |