add perl os

This commit is contained in:
songtianlun 2024-07-15 15:48:24 +08:00
parent 54274c77ac
commit 593f7062a2

View File

@ -0,0 +1,33 @@
#!/usr/bin/perl
use strict;
use warnings;
sub main {
print "Simple OS Simulator\n";
print "Type 'help' for available commands.\n";
while (1) {
print "> ";
chomp(my $input = <STDIN>);
if ($input eq 'exit') {
last;
} elsif ($input eq 'help') {
print "Available commands:\n";
print " help - show this help message\n";
print " date - show the current date and time\n";
print " echo <message> - print the given message\n";
print " exit - exit the simulator\n";
} elsif ($input =~ /^echo (.*)$/) {
print "$1\n";
} elsif ($input eq 'date') {
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
$year += 1900; $mon += 1;
print "$mon/$mday/$year $hour:$min:$sec\n";
} else {
print "Unknown command. Type 'help' for available commands.\n";
}
}
}
main();