Skip to content

Commit

Permalink
implement fmt glob
Browse files Browse the repository at this point in the history
  • Loading branch information
patch committed Dec 17, 2010
1 parent cb92f59 commit 3273c2c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/String/Fmt.pm
Expand Up @@ -24,7 +24,8 @@ sub fmt {

return sprintf $format, $value;
}
elsif ($type eq 'ARRAY') {
elsif ($type eq 'ARRAY' || $type eq 'GLOB') {
$value = [ map { chomp; $_ } <$value> ] if $type eq 'GLOB';
$format = $ARRAY_FORMAT unless defined $format;
$separator = $ARRAY_SEPARATOR unless defined $separator;

Expand Down
12 changes: 11 additions & 1 deletion t/fmt.t
@@ -1,4 +1,4 @@
use Test::More tests => 23;
use Test::More tests => 24;

use ok 'String::Fmt', qw( fmt );

Expand Down Expand Up @@ -85,3 +85,13 @@ TODO: {
is fmt([1,2]), '1 2', 'array fmt() without $fmt';
is fmt({1=>"a"}), "1\ta", 'hash fmt() without $fmt';
}

# fmt() with filehandle
{
is fmt(\*DATA, "'%s'", ', '), "'a', 'b', 'c'", 'fmt() works with filehandle';
}

__DATA__
a
b
c

0 comments on commit 3273c2c

Please sign in to comment.