in reply to Format text problem
This would allow you to change the dimensions of the columns and the names and quantity of fields without having to rewrite the sub itself.use strict; use warnings; my $player = 'Bingo'; my $parent = 'Bob'; my $memberid = 'sad324gsg'; print format_email_text(30,50, "Player Name", $player, "Parent's Name", $parent, "Member ID", $memberid); sub format_email_text { my ($name, $val, $out, $nd, $vd); $nd = shift; $vd = shift; while ($name = shift) { $val = shift; $out .= sprintf('%-'.$nd.'s %-'.$vd.'s', "$name:", $val) . "\n +"; } return $out; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Format text problem
by b310 (Scribe) on Apr 03, 2005 at 10:37 UTC | |
by nobull (Friar) on Apr 03, 2005 at 12:46 UTC |