#!/usr/bin/perl # use Recipe; use strict; my $r = Recipe->new(); sub list { my $cursor = $r->prepare("select * from ingredient;") or die $r->errstr(); $cursor->execute() or die $cursor->errstr(); print "Ingredient List:\n"; while(my @i = $cursor->fetchrow_array()) { printf "%-03.03d: %-20.20s %-40.40s\n", $i[0], $i[1], $i[2]; } return 0; } sub main { return list if not $ARGV[0] and not $ARGV[1];; my $cursor = $r->prepare("insert into ingredient values (?,?,?);") or die $r->errstr(); $cursor->execute(0, $ARGV[0], $ARGV[1]) or die $cursor->errstr(); list; } exit main; # vi: set ts=2 sw=2: #