in reply to Why SprintF?
That is, I like to store formatted data sometimes. In fact, I have written code like this:use strict; use Data::Dumper; my %dat; $dat{a} = sprintf("%5.2f", 3.141); $dat{b} = sprintf("%20s","hello"); print Dumper %dat;
use strict; use Data::Dumper; my $format_a = "%5.2f"; my $format_b = "%20s"; my %dat; $dat{a} = sprintf($format_a, 3.141); $dat{b} = sprintf($format_b,"hello"); $dat{c} = sprintf($format_a, 12.34567); print Dumper %dat; This way formats can easily be controlled in a central place.
--traveler
|
|---|