String-Format

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

# ----------------------------------------------------------------------
# Version 1.17_50                                        March 03,  2018
# ----------------------------------------------------------------------

* escape { and } (fix for RT #124147)

# ----------------------------------------------------------------------
# Version 1.14                                        December 22,  2005
# ----------------------------------------------------------------------

* Updated tests so that 04subrefs.t no longer fails if getpwuid is not
  defined.  RT#2083.

# ----------------------------------------------------------------------
# Version 1.13                                         February 11, 2002 
# ----------------------------------------------------------------------

* Modified regex to use \S, rather than a regenerated one based on
  stuff passed in. This is feasible because _replace now passes
  through everything it does not recognize.  Updated t/02basic.t to
  refect this change.

t/04subrefs.t  view on Meta::CPAN

# Test 1
# Using strftime in a subroutine reference.
# ======================================================================
$orig   = q(It is now %{%Y/%m%d}d.);
$target = sprintf q(It is now %s.), strftime("%Y/%m/%d", localtime);
$result = stringf $orig, "d" => sub { strftime("%Y/%m/%d", localtime) };
is $target => $result;

# ======================================================================
# Test 2
# using getpwuid
# ======================================================================
SKIP: {
    skip "Test skipped on this platform", 1 
        if $^O eq 'MSWin32';

    $orig   = "I am %u.";
    $target = "I am " . getpwuid($<) . ".";
    $result = stringf $orig, "u" => sub { getpwuid($<) };
    is $target => $result;
}



( run in 0.256 second using v1.01-cache-2.11-cpan-8d75d55dd25 )