package ReadFile; use Mouse::Role; use MyTypes; use IO::File; requires qw(lines); has '_io' => ( is => 'ro', isa => 'MyCompany::ReadFile', builder => '_build_read_file', handles => [ qw( open getlines close) ], init_arg => undef, lazy => 1, ); sub _build_read_file() { my $self = shift; IO::File->new(); } # sub read_file() { # my ( $self, $file ) = @_; # $self->open( $file); # my @lines = $self->getlines(); # $self->close(); # chomp(@lines); # $self->lines(\@lines); # } 1; #### package DBIxODBC; use Mouse::Role; use MyTypes; use DBIx::Simple; requires qw( user passwd dsn ); with qw(Timestamp); has 'data' => ( is => 'rw', isa => 'HashRef', trigger => \&_load, ); has '_dbix' => ( is => 'ro', isa => 'MyCompany::DBIx', handles => [qw( insert)], builder => '_build_dbix', init_arg => undef, lazy => 1, ); sub _build_dbix() { my $self = shift; my $connect_string; $connect_string = "dbi:ODBC:" . $self->dsn; DBIx::Simple->new( $connect_string, $self->user, $self->passwd ); } sub _load() { my ( $self, $input ) = @_; my $table = ( keys %$input )[0]; $self->insert( $table, $input->{$table} ); print $self->timestamp . qq(\n); } 1;