ScalarTable - scalar table component property
use Podius::Property::ScalarTable;
$d = new Podius::Property::ScalarTable(['name', 'age', 'mark']);
$d->access([['Paul', 10, 98], ['John', 12, 60], ['Jack', 11, 85]]);
print "Name\tAge\tMark\n", $d->as_string("%s"), "\n";
To write.
the Exception manpage, the Podius::Property manpage.
Modifier, 1 parameter: value to set (ARRAY of ARRAYs of scalar). Empty ARRAY unsets all rows.
Modifier, 2 parameters: ARRAY of one index [row] and ARRAY of scalar to set.
Modifier, 2 parameters: ARRAY of two indexes [row, column] and scalar to set.
Modifier, 3 parameters: offset, length and ARRAY of additional rows (i.e. ARRAY of ARRAY of scalar) - similar to the Perl built-in function splice, to delete existing and add new rows at specified offset
my $rows = $scalar_table->access; # two-dimensional ARRAY $scalar_table->access($new_rows); $scalar_table->access([1], [10, 20, 30]); $scalar_table->access([0, 2], 30); $scalar_table->access(4, 2, []); # delete fifth+sixth rows $scalar_table->access(4, 0, [[10, 20, 30]]); # add one row
# Suppose, my_table property is of type ScalarTable my $rows = $component->my_table; # two-dimensional ARRAY $component->my_table($new_rows); $component->my_table([1], [10, 20, 30]); $component->my_table([0, 2], 30); $component->my_table(4, 2, []); # delete fifth+sixth rows $component->my_table(4, 0, [[10, 20, 30]]); # add one row
* column number to access
This is an alias to as_string method.
* optional index of column to use as hash-value (or arrayref of indexes),
default is 1 if there two columns or [ 1 .. width - 1 ] if more columns
* optional index of column to use as hash-key, default is 0
In scalar context returns hashref. in list context returns plain hash.
* scalar format (optional, default is '"%s"') * outer delimiter (optional, default is "\n", example: '; ') * inner delimiter (optional, default is "\t", example: ', ')
* a list of array refs to be pushed to the end of table
This is an alias to push method.
* number of rows to add * optional array to initialize rows, [ ""* ] by default * optional boolean, if true, then add to the beggining not the end
* number of rows to delete * optional boolean, if true, then delete from the beggining not the end * optional starting index (default 0)