Posts

Showing posts from April, 2020

Perl

Perl combines the power of some of most powerful UNIX tools. It is standard on linux and also offered on solaris 8. However, it is free and executable are available for all unix system. 1. Perl Program to input a number and store it in a variable. Make a friend guess the number. Have your program tell your friend whether their guess was high, low, or correct. #! /usr/bin/perl -w print "Enter any number :"; my $ip1 = <STDIN>; print "Guess any number:"; my $ip2 = <STDIN>; if($ip2 > $ip1) {print "ip2 is greater than ip1 ";} elsif($ip2 < $ip1) {print "ip2 is smaller than ip1 ";} else {print "ip2 is equal to ip1 ";} 2. Write a program that stores a number and keeps trying to get user input until the user enters the number correctly. As soon as the correct number is entered, it prints: Correct! #! /usr/bin/perl -w my $x=16; my $y; do{ print "Enter number:"; $y=<STDIN>; }while($x!=$y)