Skip to content

Commit

Permalink
Convert away from more for $_.
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Sep 2, 2011
1 parent 289953b commit 0078144
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Text-Table/lib/Text/Table.pm
Expand Up @@ -409,12 +409,16 @@ sub add {
$tb->_entitle( [ ('') x @_] );
}

$tb->_add( @$_) for
foreach my $row (
_transpose(
[
map { [ defined() ? split( /\n/ ) : '' ] } @_
]
);
)
)
{
$tb->_add(@$row);
}
$tb->_clear_cache;

return $tb;
Expand All @@ -424,7 +428,9 @@ sub add {
sub _add {
my $tb = shift;

push @$_, shift for @{ $tb->_cols};
foreach my $col ( @{ $tb->_cols} ) {
push @{$col}, shift(@_);
}

$tb->_clear_cache;

Expand All @@ -434,9 +440,13 @@ sub _add {
# add one or more data lines
sub load {
my $tb = shift;
for ( @_ ) {
defined $_ or $_ = '';
ref($_) eq 'ARRAY' ? $tb->add( @$_) : $tb->add( split);
foreach my $row ( @_ ) {
if (!defined($row)) {
$row = '';
}
$tb->add(
(ref($row) eq 'ARRAY') ? (@$row) : (split ' ',$row)
)
}
$tb;
}
Expand Down

0 comments on commit 0078144

Please sign in to comment.