#!perl HELP "market" => "Edit market list"; my $filename = 'revbank.market'; sub _read_market() { my %market; for (slurp $filename) { /^\s*#/ and next; /\S/ or next; chomp; my ($user, $id, $seller, $space, $description) = split " ", $_, 5; $market{$id} = { user => $user, seller => $seller, space => $space, description => $description, }; } return \%market; } sub command :Tab(market,&tab) ($self, $cart, $command, @) { if ($command eq 'market') { require RevBank::TextEditor; RevBank::TextEditor::edit($filename); return ACCEPT; } my $product = _read_market->{ $command } or return NEXT; my $username = parse_user( $product->{ user }) or return NEXT; my $seller = parse_amount($product->{ seller }) or return NEXT; my $space = parse_amount($product->{ space }) or return NEXT; my $description = $product->{description}; $cart->add( -($seller + $space), "$description (sold by $username)", { product_id => $command, plugin => $self->id, deduplicate => join("/", $self->id, $command), } )->add_contra( $username, $seller, "\$you bought $description" )->add_contra( "+sales/market", $space, "\$you bought $description from $username" ); return ACCEPT; } sub tab { return grep /\D/, keys %{ _read_market() }; }