use strict;
use warnings;
my @days = qw(
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
);
my @months = qw(
January February March April May June
July August September October November December
);
sub PrintWelcome {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime();
my $thisday = $days[$wday];
my $thismon = $months[$mon];
if ($hour < 12) {
print "Good morning! ";
} elsif ($hour < 17) {
print "Good afternoon! ";
} else {
print "Good evening! ";
};
my $ampm = 'AM';
if ($hour > 12) {
$hour -= 12;
$ampm = 'PM';
}
my $time = sprintf '%d:%2.2d:%2.2d',$hour,$min,$sec;
$year += 1900;
my $datetime = "$time $ampm, $thisday, $thismon $mday, $year";
print "Just in case you were wondering, it's
";
print $datetime;
print "
Your username is $ENV{'USERNAME'} ";
print "(it\'s in \$ENV{'USERNAME'}), ";
print "the computername is $ENV{'COMPUTERNAME'} ";
print "(it\'s in \$ENV{'COMPUTERNAME'}), ";
print "and your OS is $ENV{'OS'} (it\'s in \$ENV{'OS'}).
";
print "
Here is everything in %ENV:
";
foreach my $key (sort(keys %ENV)) {
print "
$key" . " = " . $ENV{$key} . "
";
}
chomp(my @rec = `ipconfig /all`);
foreach my $itemmac (@rec) {
# Loop through ipconfig output, and find MAC address line
if ($itemmac =~ /Physical Address.*: (\S+)/) {
my $macaddr = $1; # Capture MAC address string
print "
Your MAC(Media Access Control)/Physical Address ";
print "in hexadecimal is: $macaddr
";
}
}
}
PrintWelcome();