Skip to content

Instantly share code, notes, and snippets.

@nikAizuddin
Created November 30, 2014 20:02
Show Gist options
  • Select an option

  • Save nikAizuddin/40ab28a7579dfd22ae56 to your computer and use it in GitHub Desktop.

Select an option

Save nikAizuddin/40ab28a7579dfd22ae56 to your computer and use it in GitHub Desktop.
BCN2053 Operating System Lab Sheet 6 (PERL)
#!/bin/perl
# ==========================================================
# Write a shell script, which will ask you for input 'yes'
# or 'no' and based on that will give you what is your
# input;
#
# a) If you enter yes as your input, it will echo you have
# entered yes.
#
# b) If you enter no as your input, it will echo you have
# entered no.
#
# c) No or invalid input is given, then gives error
# 'no input given'
# ==========================================================
printf("yes or no?\n");
$answer = <STDIN>;
chomp($answer); #remove newline character
if( $answer eq "yes" ) {
printf("You have entered yes\n");
} elsif( $answer eq "no" ) {
printf("You have entered no\n");
} else {
printf("No input given\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment