Math-Evol
view release on metacpan or search on metacpan
# ----------------------- choose stuff -------------------------
sub debug {
if (! open (DEBUG, '>>/tmp/clui.log')) {
warn "can't open /tmp/clui.log: $!\n"; return;
}
print DEBUG "$_[0]\n"; close DEBUG;
}
my (%irow, %icol, $nrows, $clue_has_been_given, $choice, $this_cell);
my @marked;
my $HOME = $ENV{'HOME'} || $ENV{'LOGDIR'} || (getpwuid($<))[7];
srand(time() ^ ($$+($$<15)));
sub choose { my $question = shift; local @list = @_; # @list must be local
# As from 1.22, allows multiple choice if called in array context
return unless @list;
grep (($_ =~ s/[\r\n]+$//) && 0, @list); # chop final newlines
my @biglist = @list; my $icell; @marked = ();
$question =~ s/^[\n\r]+//; # strip initial newline(s)
}
}
}
}
}
sub logit { my ($file, $msg) = @_;
if (! open(LOG, ">> $rcslog")) { warn "can't open $rcslog: $!\n";
} else {
$pid = fork; # log in background for better response time
if (! $pid) {
($user) = getpwuid($>);
print LOG ×tamp, " $file $user $msg\n"; close LOG;
if ($pid == 0) { exit 0; } # the child's end, if a fork occurred
}
}
}
sub timestamp {
# returns current date and time in "199403011 113520" format
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$wday += 0; $yday += 0; $isdst += 0; # avoid bloody -w warning
return sprintf("%4.4d%2.2d%2.2d %2.2d%2.2d%2.2d",
( run in 0.390 second using v1.01-cache-2.11-cpan-8d75d55dd25 )