Commits

Anonymous committed 96dce83

Added the optional digits+symbols parameters' prefix of the sprintf
conversion, with a simple test.

  • Participants
  • Parent commits 2b845db

Comments (0)

Files changed (2)

modules/Text-Sprintf-Named/lib/Text/Sprintf/Named.pm

 
     my $format = $self->_fmt;
 
-    $format =~ s/%(%|\(([a-zA-Z_]\w*)\)([DEFGOUXbcdefgiopsux]))/
+    $format =~ s/%(%|\(([a-zA-Z_]\w*)\)([\+\-\.\d]*[DEFGOUXbcdefgiopsux]))/
         $self->_conversion({
             format_args => $args,
             named_params => $named_params,
 
 =head1 ACKNOWLEDGEMENTS
 
+The (possibly ad-hoc) regex for matching the optional digits+symbols 
+parameters' prefix of the sprintf conversion was originally written by Bart 
+Lateur (BARTL on CPAN) for his L<String::Sprintf> module.
+
 =head1 COPYRIGHT & LICENSE
 
 Copyright 2006 Shlomi Fish, all rights reserved.

modules/Text-Sprintf-Named/t/01-use.t

 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 10;
 
 use Text::Sprintf::Named;
 
         "Testing the %(name)x and %(name)c conversions"
     );
 }
+
+{
+    # TEST
+    is (n_s("[%(name)10s]", { name => "Sophie" }),
+        "[    Sophie]",
+        "Testing a %(name)10s conversion"
+    );
+}