Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting work on moving the data fetching routines into their own module
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package KC::Data; | ||
|
||
use 5.010001; | ||
use strict; | ||
use warnings; | ||
|
||
require Exporter; | ||
|
||
our @ISA = qw(Exporter); | ||
|
||
# This allows declaration use KC::Data ':all'; | ||
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||
# will save memory. | ||
our %EXPORT_TAGS = ( | ||
'all' => [ | ||
qw( | ||
get_dates | ||
) | ||
] | ||
); | ||
|
||
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | ||
|
||
our @EXPORT = qw( | ||
); | ||
|
||
our $VERSION = '0.01'; | ||
|
||
sub get_dates { | ||
|
||
# subroutine to parse a date file and put it into a form suitable for TT | ||
open( my $FH, '<', 'data/dates.txt' ); | ||
my @dates; | ||
while ( my $line = <$FH> ) { | ||
my ( $date, $desc ) = split( '|', $line ); | ||
my $daterow = { | ||
'date' => $date, | ||
'desc' => $desc | ||
} push @dates, $daterow; | ||
} | ||
close $FH; | ||
return \@dates; | ||
|
||
} | ||
|
||
1; | ||
__END__ |