1. Shlomi Fish
  2. perl-Text-Sprintf


shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed 9ff47aa

Got all tests to pass.

  • Participants
  • Parent commits 2a597bb
  • Branches default

Comments (0)

Files changed (3)

File modules/Text-Sprintf-Named/Changes

View file
  • Ignore whitespace
 Revision history for Text::Sprintf::Named
-0.01    Date/time
+0.01    TODO : Fill the time.
         First version, released on an unsuspecting world.

File modules/Text-Sprintf-Named/README

View file
  • Ignore whitespace
-The README is used to introduce the module and provide instructions on
-how to install the module, any machine dependencies it may have (for
-example C compilers and installed libraries) and any other information
-that should be provided before the module is installed.
+This module provides a sprintf-like function with named conversions (similar 
+to the one in Python). So for example the call:
-A README file is required for CPAN modules since CPAN extracts the README
-file from a module distribution so that people browsing the archive
-can use it get an idea of the modules uses. It is usually a good idea
-to provide version information here so that people can decide whether
-fixes for the module are worth downloading.
+    named_sprintf("Hello %(name)s! Happy new %(year)d!", 
+        { name => "Sophie", year => 2007 }
+    );
+Will return "Hello Sophie! Happy new 2006!".
 Copyright (C) 2006 Shlomi Fish
-This program is released under the following license: bsd
+This program is released under the following license: MIT X11. 

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

View file
  • Ignore whitespace
 =head1 NAME
-Text::Sprintf::Named - The great new Text::Sprintf::Named!
+Text::Sprintf::Named - sprintf-like function with named conversions
 =head1 VERSION
 =head1 SYNOPSIS
-Quick summary of what the module does.
-Perhaps a little code snippet.
     use Text::Sprintf::Named;
-    my $foo = Text::Sprintf::Named->new();
-    ...
+    my $formatter =
+        Text::Sprintf::Named->new(
+            {fmt => "Hello %(name)s! Today is %(day)s!"
+        );
+    # Returns "Hello Ayeleth! Today is Sunday!"
+    $formmater->format({'name' => "Ayeleth", 'day' => "Sunday"});
+    # Returns "Hello John! Today is Thursday!"
+    $formatter->format({'name' => "John", 'day' => "Thursday"});
+Text::Sprintf::Named provides a sprintf equivalent with named conversions.
+Named conversions are sprintf field specifiers (like C<"%s"> or C<"%4d>")
+only they are associated with the key of an associative array of
+parameters. So for example C<"%(name)s"> will emit the C<'name'> parameter
+as a string, and C<"%(num)4d"> will emit the C<'num'> parameter 
+as a variable with a width of 4.
 =head1 EXPORT
 A list of functions that can be exported.  You can delete this section
 if you don't export anything, such as for a purely object-oriented module.
-=head2 function1
-sub function1 {
-=head2 function2
-sub function2 {
 =head1 AUTHOR
 Shlomi Fish, C<< <shlomif at cpan.org> >>
 Copyright 2006 Shlomi Fish, all rights reserved.
-This program is released under the following license: bsd
+This program is released under the following license: MIT X11. 
+(Note that the module's meta-data specifies it's distributed under the BSD 
+license, which is the closest option to the MIT X11 license.)