Created
November 30, 2014 20:02
-
-
Save nikAizuddin/40ab28a7579dfd22ae56 to your computer and use it in GitHub Desktop.
BCN2053 Operating System Lab Sheet 6 (PERL)
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
| #!/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