You are looking at a dusty script called cowheart


#!/usr/bin/perl

#-- define vars..
$appname = "COWheart";
$appdesc ="central processor for COW";
$appversion = "1.1";
$infile = "objects.dsv";
$continuefile = "stop.flg";
$cmdcue = "cmdcue.txt";
$tmpsrc = "cmdcue-original.txt";
$onesec = 1;

#-- start code..

print "Content-type: text/html

";
print <$appname $appversion - $appdesc

$appname $appversion $appdesc

Started..
EOF

#link($tmpsrc,$cmdcue);

&loadDataset;

# loop round reading lines from cmd cue file
while () {
open(INPUT,"<$continuefile") || die "End of $appname $appversion";
close (INPUT);
# print "!";
&processcmds;
sleep $onesec;
}

#-- start functions..

#process cmds un the cue-------------------------------------
sub processcmds {
open(INPUT,"<$cmdcue") || die "Can't input $infile $!";
#truncate($cmdcue,0);
unlink ;
@pairs = ;
close (INPUT);
foreach $item(@pairs) {
print "^ $item
";
}
}

#convert spaces in strings to %20's----------------------------
sub pad {
# take passed variable..
$tmp = @_[0];
# convert spaces to %20's..
$tmp =~ s/ /'%20'/ge;
# return result..
return $tmp;
}

#load object database -----------------------------------------
sub loadDataset {
open(INPUT,"<$infile") || die "Can't input $infile $!";
@pairs = ;
close (INPUT);
print "

COW $version, ";
foreach $item(@pairs) {
chop($item);
($key,$value) = split(/=/,$item,2);
$db{$key}=$value;
$count++;
}
print "$count objects


";
}

# find an objects number by its name -----------------------------
sub findObjName {
#define temp var to hold passed objname, location and ultimate in..
my $objname = @_[0];
my $loc = @_[1];
my $ult = @_[2];

# split into words..
@words = split(/ /,@_[0]);
shift @words;
# must be a better way of finding last word..
foreach $wd(@words) {
#build list of attribs..
push(@attribs,$wd);
$objname = $wd;
}
# loose objname from list of attribs..
pop(@attribs);

# get matching value from db..
@objects = split(/\\,/,$db{$objname});

# test each object with this name as the db returns a list of objs with the same name..
foreach $thisobj(@objects) {
if (length($thisobj)>0) {
# grab all the elements..
$thisobj =~ /(.*)\\[(.*)\\](.*)/i;
push(@valid,$2);
if ($loc>-1 && $1 != $loc) { $_ = pop(@valid)}
elsif ($ult>-1 && $3 != $ult) { $_ = pop(@valid)}
else {
$testobj = $db{$2};
foreach $at(@attribs) {
if ($testobj =~ ?.*$at.*?i) {
# attrib matched..
} else {
# attrib didnt match..
pop(@valid);
}
}
}
}
}
#fix: how do we handle multiple matches?.. for now return first match..
# foreach $objnum(@valid) {
# $value=$db{$objnum};
# # print "object $objnum=$value";
#}

# return what was found..
return $valid[0]; }

sub descobj {
# describes an object - find by number, detail level passed..
my $objname = @_[0];
my $detail = @_[1];

}
sub resolveqty() {
# resulves the qty word into a number..
$words = @_[0];
$db{$objnum};
# split into words..
@words = split(/ /,$words);
foreach $word(@words) {
}

}