Data-Presenter
view release on metacpan or search on metacpan
lib/Data/Presenter.pm view on Meta::CPAN
like this:
Monday, 9:00 Arithmetic E Jones 4044 4044_11
Monday, 9:00 Language Studies T Wilson 4054 4054_11
Monday, 10:00 Bible Study M Eliade 4068 4068_12
Monday, 10:00 Introduction to Computers D Knuth 4086 4086_12
Monday, 11:00 Psychology A Adler 4077 4077_13
Monday, 11:00 Social Science T Jones 4044 4044_13
Friday, 9:00 World History H Wells 4052 4052_51
Friday, 9:00 Music Appreciation W Wilson 4044 4044_51
Usage of C<writedelimited_with_reprocessing()> requires that the administrator
appropriately define C<Data::Presenter::[Package1]::_reprocess_delimit()> and
C<Data::Presenter::[Package1]::_init()> subroutines in the invoking package,
along with appropriate subroutines specific to each argument capable of being
reprocessed. Again, see the discussion in L<"writeformat_with_reprocessing()">.
=head3 C<writedelimited_deluxe()>
C<writedelimited_deluxe()> is an advanced
application of Data::Presenter and the reader may wish to skip this section
until other parts of the module have been mastered.
C<writedelimited_deluxe()> completes the parallel structure between the
C<writeformat...()> and C<writedelimited...()> families of Data::Presenter
methods by enabling the user to have I<both> column headers (as in
C<writedelimited_plus_header()>) and dynamic, 'just-in-time' reprocessing of
data in selected fields (as in C<writedelimited_with_reprocessing()>). Except
for the name of the method called, the call to C<writedelimited_deluxe()> is
the same as for C<writedelimited_with_reprocessing()>:
@reprocessing_info = qw( instructor timeslot );
$dp1->writedelimited_deluxe(
sorted => $sorted_data,
columns => \@columns_selected,
file => $outputfile,
delimiter => $delimiter,
reprocess => \@reprocessing_info,
);
Using the classroom scheduling example from above,the output from
C<writedelimited_deluxe()> might look like this:
Timeslot Group Instructor Room GroupID
Monday, 9:00 Arithmetic E Jones 4044 4044_11
Monday, 9:00 Language Studies T Wilson 4054 4054_11
Monday, 10:00 Bible Study M Eliade 4068 4068_12
Monday, 10:00 Introduction to Computers D Knuth 4086 4086_12
Monday, 11:00 Psychology A Adler 4077 4077_13
Monday, 11:00 Social Science T Jones 4044 4044_13
Friday, 9:00 World History H Wells 4052 4052_51
Friday, 9:00 Music Appreciation W Wilson 4044 4044_51
As with C<writedelimited_with_reprocessing()>, C<writedelimited_deluxe()>
requires careful preparation on the part of the administrator. See the
discussion under L<"writeformat_with_reprocessing()"> above.
=head3 C<writeHTML()>
In its current formulation, C<writeHTML()> works very much
like C<writeformat_plus_header()>. It writes data to an operator-specified
HTML file and writes an appropriate header to that file as well.
C<writeHTML()> takes the same 4 arguments as C<writeformat_plus_header()>:
C<$sorted_data>, C<\@columns_selected>, C<$outputfile> and C<$title>. The
body of the resulting HTML file is more similar to a Perl format than to an
HTML table. (This may be upgraded to a true HTML table in a future release.)
$dp1->writeHTML(
sorted => $sorted_data,
columns => \@columns_selected,
file => $HTMLoutputfile, # must have .html extension
title => $title,
);
=head2 Data::Presenter::Combo Objects
It is quite possible that we may have two or more different database reports
which present data on the same underlying universe or population. If these
reports share a common index field which can be used to uniquely identify
each entry in the underlying population, then we would like to be able to
combine these sources, manipulate the data and re-output them via the simple
and complex Data::Presenter output methods described in the L<"Synopsis">
above.
In other words, if we have already created
my $dp1 = Data::Presenter::[Package1]->new(
$sourcefile, \@fields,\%parameters, $index);
my $dp2 = Data::Presenter::[Package2]->new(
$sourcefile, \@fields,\%parameters, $index);
...
my $dpx = Data::Presenter::[Package2]->new(
$sourcefile, \@fields,\%parameters, $index);
we would like to be able to define an array of the objects we have created
and construct a new object combining the first two in an orderly manner:
my @objects = ($dp1, $dp2, ... $dpx);
my $dpC = Data::Presenter::[some subclass]->new(\@objects);
We would then like to be able to call all the Data::Presenter sorting,
selecting and output methods discussed above on C<$dpC> B<without having to
re-specify C<$sourcefile>, C<\@fields>, C<\%parameters> or C<$index>>.
Can we do this? Yes, we can. More precisely, we can create I<two> new types
of objects: one in which the data entries comprise those entries found in
I<each> of the original sources, and one in which the data entries comprise
those found in I<any> of the sources. In mathematical terms, we can create
either a new object which represents the I<intersection> of the sources or
one which represents the I<union> of the sources. We call these as follows:
my $dpI = Data::Presenter::Combo::Intersect->new(\@objects);
and
my $dpU = Data::Presenter::Combo::Union->new(\@objects);
Note the following:
=over 4
( run in 1.065 second using v1.01-cache-2.11-cpan-5837b0d9d2c )