package Apache::FastForward::Spreadsheet; # Copyright 2006 Jerzy Wachowiak use strict; use warnings; use Carp; use Text::CSV_XS; use vars qw( $VERSION ); $VERSION = '1.01'; # Perl tie methods: DELETE, CLEAR, EXISTS, FIRSTKEY, NEXTKEY, # SCALAR, UNTIE, DESTROY are not implemented as the package # mimics a spreadsheet array of array behaviour sub TIEHASH { my $class = shift; my $self = {}; $self->{VERSION} = $VERSION; $self->{template} = []; bless ( $self, $class ); return $self } sub LoadTemplate { #Contract: # [1] Path to a CSV file and CSV parameters as input # [2] Method can either suceed (true) or everything dies... my $self = shift; my $path = shift; my $csv_atrributes = shift; defined( $csv_atrributes ) or croak 'Missing CSV parameters for spreadsheet template'; my $csv = Text::CSV_XS->new( $csv_atrributes ); open( TEMPLATE, '< '.$path ) or croak "Spreadsheet template $path -> $!"; while ( defined( my $line =