Write a program which asks the user for his/her first name and last name, and then prints out a line of text welcoming him/her using the given names. (solution)
Write a program which reads lines until it reads a "." on a line by itself,
then prints out all of the lines it has read in reverse order. (solution)
# Read lines until a line consisting only of "." is seen.
# Then print the lines back out in the opposite order.
my @lines;
while ( $line = <> and $line ne ".\n" )
{
push @lines, $line;
}
foreach ( reverse @lines ) # only reverses the list used by foreach; d
+oes not modify the array
{
print;
}
# prompt for and read First and Last name, then print a welcome messag
+e.
print "\nWhat is your first name? ";
my $first = <>;
print "\nWhat is your last name? ";
my $last = <>;
chomp $first; # strip the newline from the first name
print "Welcome $first $last";