in reply to Re^2: The cognitive load of generated code
in thread The cognitive load of generated code

I see what you mean. The lack of parentheses on length and especially int is ambiguous. I remember having to test int once to see if something like int $a / 2 means int($a) / 2 or int($a / 2) and since it meant the latter I adopted that bad habit. I could probably write a book: Perl Worst Practices! Thanks for the clues.
sub shortencentered { my $f = defined $_[0] ? shift : return ''; # be less weird :-) my $m = shift || 42; return $f if length($f) <= $m; my $a = $m - 3; my $s = int($a / 2); my $e = $a - $s; return substr($f, 0, $s) . '...' . substr($f, -$e) }