Last active
November 24, 2015 22:55
-
-
Save charleyramm/7f615d95e7c606e5d0fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$OUTPUT_AUTOFLUSH = 1; # this thing turns off buffering between newlines | |
while (1) { | |
print "perl% "; | |
my $command = <STDIN>; # get some user input | |
last if $command eq ''; # exit the loop | |
chomp $command; # remove newline from our input | |
my ($program, @args) = split /\s+/, $command; | |
my $pid = fork; | |
if (! defined $pid) { print STDERR "Couldn't fork: $!\n" } | |
elsif ($pid != 0) { wait } # I am the parent | |
else { exec $program, @args; # I am the child | |
die "Couldn't exec: $!\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment