package Text::Autoformat::Agenda; require 5.005_62; use strict; use warnings; require Exporter; our @ISA = qw(Exporter); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use Text::Autoformat::Agenda ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. our %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw( ); our $VERSION = '0.01'; our $incr; our $depth; # Preloaded methods go here. sub new { my $class = shift; my %config = @_; my $self = bless \%config, $class; } sub tab { " " x (@_ ? $depth+$_[0] : $depth) } sub verbose_add_content { printf "depth: %d adding: ((%s))\n", $depth, $_[1]; $_[0] .= $_[1] } sub proc_array { my $self = shift; my $content; ++$depth; local $incr; while (@_) { my ($key,$val) = splice @_, 0, 2; if (!ref($val)) { ++$incr; my $F="$self->{Dir}/$val"; open F, $F or die "Couldnt open $F: $!"; my $_content; while () { $_content .= sprintf "%s%s", tab(1), $_; } my $bullet = sprintf "%s%s. %s\n%s", tab, $incr, $key, $_content; verbose_add_content($content,$bullet); # $content .= $bullet; } else { my $bullet = sprintf "%s%s. %s\n%s", tab, ++$incr, $key, $self->proc_array(@$val); verbose_add_content($content,$bullet); # $content .= $bullet ; } } --$depth; $content; } sub content { my $self = shift; my $body = $self->proc_array(@{$self->{Agenda}}); "$self->{Title}\n\n$body"; } 1; __END__ # Below is stub documentation for your module. You better edit it! =head1 NAME Text::Autoformat::Agenda - Automated agenda creation from flat files =head1 SYNOPSIS use Text::Autoformat::Agenda; # requires Text::Autoformat use Date::Business # not required. just useful for my agendas my $d = new Date::Business(FORCE => 'next'); my ($year,$month,$day) = ($d->image =~ /(.{4})(.{2})(.{2})/); my $pretty_date = "$month-$day-$year"; my $agenda = Text::Autoformat::Agenda->new ( Dir => '/home/tmbranno/status', Title => "Status report for the week ending $pretty_date", Agenda => [ "Accomplishments in the past week" => 'accomplishments.txt', "Plans for the next week" => [ General => 'plans.txt', Vacations => 'vacations.txt', Classes => 'classes.txt' ], "Outstanding issues" => 'issues.txt' ] ); print $agenda->content; =head1 DESCRIPTION Stub documentation for Text::Autoformat::Agenda, created by h2xs. It looks like the author of the extension was negligent enough to leave the stub unedited. Blah blah blah. =head2 EXPORT None by default. =head1 AUTHOR A. U. Thor, a.u.thor@a.galaxy.far.far.away =head1 SEE ALSO perl(1). =cut