5) Write a program that asks two people for their names; stores the names in variables called $name1 and $name2; says hello to both of them. #!/usr/local/bin/perl -w # # A program for greeting people # print "What is your name? "; $name1 = ; chomp ($name1); print "What is your name? "; $name2 = ; chomp ($name2); print "Hello, $name1 and $name2! How are you?\n"; -------------------------------------------------------- 7) Write a script that asks a user for a number. The script adds 3 to that number. Then multiplies the result by 2, subtracts 4, subtracts twice the original number, adds 3, then prints the result. #!/usr/local/bin/perl -w # # Magically guessing a number # print "Please, type in a number: "; $number = ; chomp ($number); $newresult = (($number + 3) * 2) - 4; $finalresult = $newresult - (2 * $number) + 3; print "The result is $finalresult.\n"; -------------------------------------------------------- 8) Write a script that asks users for the temperature in F and prints the temperature in C. (Conversion: Celsius = (F - 32) * 5/9 ) #!/usr/local/bin/perl -w # # This program converts F to C # print "What is the temperature in degrees F?"; $F = ; chomp $F; $C=(($F-32)*(5/9)); print "The temperature in C is $C\n"; -------------------------------------------------------- 9) Write Perl print statements for the following text: print "Snoopy bought a CD called \"Greatest Hits\" on the WWW for\n"; print "\$10.00. To buy the CD he had to send an email message to\n"; print "orders\@hits-online.net. This is what the design on the CD\n"; print "cover looked like:\n\n"; print "\t\\ | /\n"; print "\t \@ \@\n"; print "\t *\n"; print "\t \\---/\n"; -------------------------------------------------------- 10) Write a program that asks users for their favourite color. Create the following output (assuming "red" is the chosen color). red red red red red red red red red red red red red red red red red red red red red red red red #!/usr/local/bin/perl -w # # program that demonstrates operating with strings # print "Please, type your favourite color: "; $color= ; chomp $color; $color = $color . " "; $color2 = $color x 10; print "$color2\n"; print "$color\t\t\t\t\t$color\n"; print "$color\t\t\t\t\t$color\n"; print "$color2\n";