in reply to Re^2: The cognitive load of generated code
in thread The cognitive load of generated code
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) }
|
|---|