{"id":16112368,"url":"https://github.com/briandfoy/string-sprintf","last_synced_at":"2025-07-19T20:07:10.033Z","repository":{"id":33859523,"uuid":"37566155","full_name":"briandfoy/string-sprintf","owner":"briandfoy","description":"The String::Sprintf Perl module","archived":false,"fork":false,"pushed_at":"2025-03-10T22:51:33.000Z","size":107,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-10T23:31:18.240Z","etag":null,"topics":["perl","perl-module"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/briandfoy.png","metadata":{"files":{"readme":"README","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-17T01:46:24.000Z","updated_at":"2025-03-10T22:51:37.000Z","dependencies_parsed_at":"2024-01-05T18:33:07.292Z","dependency_job_id":"1d5c6ab8-3fb6-4886-a53b-67b231dd5add","html_url":"https://github.com/briandfoy/string-sprintf","commit_stats":{"total_commits":65,"total_committers":3,"mean_commits":"21.666666666666668","dds":"0.24615384615384617","last_synced_commit":"28f05f18a1daaf1f4c93e4b2f7aeea735439eafc"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandfoy%2Fstring-sprintf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandfoy%2Fstring-sprintf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandfoy%2Fstring-sprintf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/briandfoy%2Fstring-sprintf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/briandfoy","download_url":"https://codeload.github.com/briandfoy/string-sprintf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243911232,"owners_count":20367648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["perl","perl-module"],"created_at":"2024-10-09T20:07:23.063Z","updated_at":"2025-03-18T09:31:07.618Z","avatar_url":"https://github.com/briandfoy.png","language":"Perl","readme":"INSTALLATION\n\nYou should be able to use this set of instructions to install the module:\n\nperl Makefile.PL\nmake\nmake test\nmake install\n\nIf you are on a windows box you should use 'nmake' rather than 'make'.\n\nIf you don't have (n)make then you can install the module manually by simply\ncopying the contents of the 'lib' subdirectory from the archive, into a\ndirectory that is in @INC, for example the subdirectory site/lib, somewhere\nin the perl file tree. Run this one-liner to see your default options.\n\n  perl -le \"print for @INC\"\n\nAlternatively, put it in a place that you add to @INC yourself, using\n\"use lib\", the command line switch \"-I\", or the environment variable\n\"PERL5LIB\".\n\nYou can manually run the tests, before installation, by running the following\ncommand line for each test file in the subdirectory \"t\", from the directory\nthat contains the Makefile.PL:\n\n  perl -Ilib t/001_load.t\n\n\nWhat follows, is a text only rendering of the docs.\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module. For example, I foresee no reason for\n    subclassing.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module. For example, I foresee no reason for\n    subclassing.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module. For example, I foresee no reason for\n    subclassing, and all formatters behave differently. That's what they're\n    for.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module. For example, I foresee no reason for\n    subclassing, and all formatters behave differently. That's what they're\n    for.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\nNAME\n    String::Sprintf - Custom overloading of sprintf\n\nSYNOPSIS\n        use String::Sprintf;\n        my $f = String::Sprintf-\u003eformatter(\n          N =\u003e sub {\n            my($width, $value, $values, $letter) = @_;\n            return commify(sprintf \"%${width}f\", $value);\n          }\n        );\n\n        my $out = $f-\u003esprintf('(%10.2N, %10.2N)', 12345678.901, 87654.321);\n        print \"Formatted result: $out\\n\";\n\n        sub commify {\n            my $n = shift;\n            $n =~ s/(\\.\\d+)|(?\u003c=\\d)(?=(?:\\d\\d\\d)+\\b)/$1 || ','/ge;\n            return $n;\n        }\n\nDESCRIPTION\n    How often has it happened that you wished for a format that (s)printf\n    just doesn't support? Have you ever wished you could overload sprintf\n    with custom formats? Well, I know I have. And this module provides a way\n    to do just that.\n\nUSAGE\n    So what is a formatter? Think of it as a \"thing\" that contains custom\n    settings and behaviour for sprintf. Any formatting style that you don't\n    set (\"overload\") falls back to the built-in keyword sprintf.\n\n    You can make a minimal formatter that behaves just like sprintf (and\n    that is actually using sprintf internally) with:\n\n      # nothing custom, all default:\n      my $default = String::Sprintf-\u003eformatter();\n      print $default-\u003esprintf(\"%%%02X\\n\", 35);\n      # which produces the same result as:\n      print sprintf(\"%%%02X\\n\", 35);   # built-in\n\n    Because of the explicit use of these formatters, you can, of course, use\n    several different formatters at the same time, even in the same\n    expression. That is why it's better that it doesn't actually *really*\n    overload the built-in sprintf. Plus, it was far easier to implement this\n    way.\n\n    The syntax used is OO Perl, though I don't really consider this as an\n    object oriented module. For example, I foresee no reason for\n    subclassing, and all formatters behave differently. That's what they're\n    for.\n\nMETHODS\n  class method:\n   formatter( 'A' =\u003e \\\u0026formatter_A, 'B' =\u003e \\\u0026formatter_B, ... )\n    A constructor. This returns a formatter object that holds custom\n    formatting definitions, each associated with a letter, for its method\n    \"sprintf\". Its arguments consist of hash-like pairs of each a formatting\n    letter (case sensitive) and a sub ref that is used for callbacks, and\n    that is expected to return the formatted substring.\n\n  callback API\n    A callback is supposed to behave like this:\n\n      sub callback {\n          my($width, $value, $values, $letter) = @_;\n          ...\n          return $formatted_string;\n      }\n\n   Arguments: my($width, $value, $values, $letter) = @_;\n    There are 4 arguments passed to the callback functions, in order of\n    descending importance. So the more commonly used parameters come first -\n    and yes, that's my mnemonic. They are:\n\n   $width\n    The part that got put between the '%' and the letter.\n\n   $value\n    The current value from the arguments list, the one you're supposed to\n    format.\n\n   $values = \\@value\n    An array ref containing the whole list of all passed arguments, in case\n    you want to support positional indexed values by default, as is done in\n    strftime\n\n   $letter\n    The letter that caused the callback to be invoked. This is only provided\n    for the cases where you use a common callback sub, for more than one\n    letter, so you can still distinguish between them.\n\n   return value: a string\n    The return value in scalar context of this sub is inserted into the\n    final, composed result, as a string.\n\n  instance method:\n   sprintf($formatstring, $value1, $value2, ...)\n    This method inserts the values you pass to it into the formatting\n    string, and returns the constructed string. Just like the built-in\n    sprintf does.\n\n    If you're using formatting letters that are *not* provided when you\n    built the formatter, then it will fall back to the native formatter:\n    \"sprintf\" in perlfunc. So you need only to provide formatters for which\n    you're not happy with the built-ins.\n\nEXPORTS\n    Nothing. What did you expect?\n\nTODO\n    Support for overloading strftime is planned for the next release (soon),\n    and proper support for position indexed values, like \"%2$03X\", is next\n    (also soon).\n\nSEE ALSO\n    \"sprintf\" in perlfunc, sprintf(3), \"strftime\" in POSIX\n\nBUGS\n    You tell me...?\n\nSUPPORT\n    Poke me at Perlmonks (username \"bart\" - I'm often hanging around in the\n    Chatterbox), or mail me.\n\nAUTHOR\n        Bart Lateur\n        CPAN ID: BARTL\n        Me at home, eating a hotdog\n        bart.lateur@pandora.be\n        L\u003chttp://perlmonks.org/?node=bart\u003e\n        L\u003chttp://users.pandora.be/bartl/\u003e\n\nCOPYRIGHT\n    (c) Bart Lateur 2006.\n\n    This program is free software; you can redistribute it and/or modify it\n    under the same terms as Perl itself.\n\n    My personal terms are like this: you can do whatever you want with this\n    software: bundle it with any software, be it for free, released under\n    the GPL, or commercial; you may redistribute it by itself, fix bugs, add\n    features, and redistribute the modified copy. I would appreciate being\n    informed in case you do the latter.\n\n    What you may not do, is sell the software, as a standalone product.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriandfoy%2Fstring-sprintf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbriandfoy%2Fstring-sprintf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbriandfoy%2Fstring-sprintf/lists"}