package Mikes::Menu; use strict; use Time::localtime; use Exporter; use strict; use warnings; #use carp qw(croak); # Need to figure out for the die funtions. Die looks bad in a module. our(@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION); @ISA=qw(Exporter); @EXPORT=qw(win_clear nix_clear char new_char char_new new_char_new head head_new right right_new left left_new); @EXPORT_OK=qw(logit); %EXPORT_TAGS=( all => [ @EXPORT ] ) ; $VERSION = 0.09; #my $pass = ($char,$width) sub char { print "$_[0]" x "$_[1]"; } sub new_char { newline(); char(@_); } sub char_new { char(@_); newline(); } sub new_char_new { # my $char = shift; # my $width = shift; my ($char,$width) = @_; newline(); char($char,"1"); char($char,$width); newline(); } sub win_clear { #my $cls= system `cls`; #my $cls = system "cls"; # print $cls; system "cls"; #system "cls\n"; #my $clear = system "cls"; #chop $clear; #print $clear; } sub nix_clear { system "clear\n"; } sub newline { print "\n"; } sub head { char($_[0],$_[1]); center(@_); char($_[0],$_[1]); } sub center { my $h1; my $h2; my $test = length ($_[2]); my $space = $_[1] - $test; my $half = $space / "2" - "1"; if($half =~ /^\d\d\.5$/){ # if($half =~ /^\d\d\.5$/){ $h1 = $half + ".5"; $h2 = $half - ".5"; } else { $h2 = $half; $h1 = $half; } char($_[0],"1");char(" ","$h1");print"$_[2]";char(" ","$h2");char($_[0],"1"); } sub center_new { my $h1; my $h2; my $test = length ($_[2]); my $space = $_[1] - $test; my $half = $space / "2" - "1"; if($half =~ /^\d\d\.5$/){ $h1 = $half + ".5"; $h2 = $half - ".5"; } else { $h2 = $half; $h1 = $half; } char($_[0],"1");char(" ","$h1");print"$_[2]";char(" ","$h2");char($_[0],"1"); newline(); } sub head_new { char_new($_[0],$_[1]); center_new(@_); char_new($_[0],$_[1]); } sub right # think of new name for left justify. { my $test = length ($_[2]); my $space = $_[1] - $test; my $space2 = $space - "2"; char($_[0],"1");char(" ",$space2);print"$_[2]";char($_[0],"1"); # char($_[0],"1");print"$_[2]";char(" ",$space2);char($_[0],"1"); } sub right_new { my $test = length ($_[2]); my $space = $_[1] - $test; my $space2 = $space - "2"; char($_[0],"1");char(" ",$space2);print"$_[2]";char($_[0],"1"); newline(); } sub left { my $test = length ($_[2]); my $space = $_[1] - $test; my $space2 = $space - "2"; char($_[0],"1");print"$_[2]";char(" ",$space2);char($_[0],"1"); } sub left_new { my $test = length ($_[2]); my $space = $_[1] - $test; my $space2 = $space - "2"; char($_[0],"1");print"$_[2]";char(" ",$space2);char($_[0],"1"); newline(); } sub logit { my $user = getlogin() || getpwuid($<) || die print "Cannot Determine Username"; my $str = shift; my $file = shift || "c:/default_log.txt" || "/home/$user/default_log.txt"; my ($wday, $month, $day, $t, $year)=split(/\s+/, ctime); open (LOGFILE, ">>$file") or print "logit failed to append log file"; print (LOGFILE "$year $month\-$day $t " . "$str\n"); # return ("$month\-$day $t " . "$str"); close LOGFILE; } 1 #### #!/usr/bin/perl use Mikes::Menu; @_= qw(- 80 Mikes_test_menu); head(@_);