in reply to conditional string formatting
my %formats = ( 1 => ' %s ', 2 => ' %s ', 3 => ' %s', 4 => '%s', ); for my $x ("a", "bb", "ccc", "dddd") { printf $formats{length($x)}, $x; print "\n"; } ###################### a bb ccc dddd
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: conditional string formatting
by AnomalousMonk (Archbishop) on Jun 10, 2015 at 00:34 UTC | |
by QM (Parson) on Jun 10, 2015 at 08:39 UTC | |
by AnomalousMonk (Archbishop) on Jun 10, 2015 at 14:00 UTC |