Thread Formatierte Ausgabe / Platzhalter ... aber wie ?
(23 answers)
Opened by cherished at 2008-06-26 11:29 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 print _stringFormat('12345', 10) ; print _stringFormat('huhu longlongbimbambuhh', 15); print _stringFormat('bimbam'), 20) . "\n"; print _stringFormat('123', 10) ; print _stringFormat('huhu', 15); print _stringFormat('bimbam'), 20) . "\n"; sub _stringFormat { my $c = ($_[1] - length($_[0])) < 0 ? 0 : $_[1] - length($_[0]); $_[0] = substr($_[0], 0, $_[1]-4) . "... " if (length($_[0]) >= $_[1]); return $_[0] . " " x $c; } Last edited: 2020-06-01 14:02:35 +0200 (CEST) |