| 1 | # perl | ||
| 2 | # | ||
| 3 | # Minimal report example using shortest options, | ||
| 4 | # data rows given as hash references | ||
| 5 | # | ||
| 6 | # PORF Perl Open Report Framework | ||
| 7 | # | ||
| 8 | # Ralf Peine, Wed May 14 10:39:49 2014 | ||
| 9 | # | ||
| 10 | #------------------------------------------------------------------------------ | ||
| 11 | |||
| 12 | use warnings; | ||
| 13 | use strict; | ||
| 14 | |||
| 15 | use Report::Porf::Framework; | ||
| 16 | |||
| 17 | sub run_example { | ||
| 18 | my $person_rows = shift; # Param1: Reference to list of hashes | ||
| 19 | my $format = shift; # Param2: Optional: format of report | ||
| 20 | |||
| 21 | $format = 'text' unless $format; | ||
| 22 | |||
| 23 | # --- create Report ------------------------------------------------------- | ||
| 24 | my $report_frame_work = Report::Porf::Framework::get(); | ||
| 25 | my $r = $report_frame_work->create_report($format); | ||
| 26 | |||
| 27 | # $r->set_verbose(3); # uncomment to see infos about configuring phase | ||
| 28 | |||
| 29 | # --- Configure Report ---------------------------------------------------- | ||
| 30 | |||
| 31 | $r->cc(-h => 'Prename', -vn => 'Prename'); | ||
| 32 | $r->cc(-h => 'Surname', -vn => 'Surname'); | ||
| 33 | $r->cc(-h => 'Age', -vn => 'Age' ); | ||
| 34 | |||
| 35 | $r->configure_complete(); | ||
| 36 | |||
| 37 | # --- print out table ----------------------------------- | ||
| 38 | |||
| 39 | $r->write_all($person_rows); # print STDOUT ... | ||
| 40 | |||
| 41 | # --- return count of entries --------------------------- | ||
| 42 | |||
| 43 | return (scalar @{$person_rows}); | ||
| 44 | } | ||
| 45 | |||
| 46 | 1; |