### Create some entries in various CSV tables
# Maria is a person
aid add person maria
# HSBC is a bank
aid add bank hsbc
# Perlmonk is a website
aid add website perlmonks
### List them all, and check for existence
aid list person
aid listed person maria
### Operations
# There is £100 in maria's bank account
aid set hsbc maria 100
# How much is there, again?
aid get hsbc maria # £100
# Maria wrote 25 posts on Perlmonks
aid set maria perlmonks 25
# How much?
aid get maria perlmonks
### More to come...
####
use Function::Parameters; # works with App::Rad, while Kavorka doesn't
fun add ($c) {
my ($data, $data_type) = @{_process_data($c)};
my ($name) = @{$c->argv};
$data->add($name);
}
# $data is a wrapper object to a csv file: person.csv / bank.csv / etc
# This way I can delegate the work to these different entities
# $data_type is not used here, but could be used to display a message
####
use Class::Method::Modifiers;
around 'add' => sub {
my $orig = shift;
my $c = shift;
my ($data, $data_type) = @{_process_data($c)};
my ($name) = @{$c->argv};
$orig->($data, $data_type, $name, @_);
};
sub add ($data, $data_type, $name) {
$data->add($name);
}
####
Can't locate object method "add" via package "App::Rad" at bin/arb-aid.pl line 58.
main::add('App::Rad=HASH(0xa20010)') called at /home/user/.perlbrew/libs/perl-5.16.3@devel/lib/perl5/App/Rad/Command.pm line 251
App::Rad::Command::run('App::Rad::Command=HASH(0x1ac72c0)', 'App::Rad=HASH(0xa20010)') called at /home/user/.perlbrew/libs/perl-5.16.3@devel/lib/perl5/App/Rad.pm line 598
App::Rad::__ANON__('App::Rad=HASH(0xa20010)') called at /home/user/.perlbrew/libs/perl-5.16.3@devel/lib/perl5/App/Rad.pm line 321
App::Rad::_run_full_round('App::Rad=HASH(0xa20010)', 'CODE(0xa34138)') called at /home/user/.perlbrew/libs/perl-5.16.3@devel/lib/perl5/App/Rad.pm line 602
App::Rad::run('App::Rad') called at bin/arb-aid.pl line 2