Exercise 6.3D

From Earlham CS Department
Revision as of 11:44, 18 December 2009 by Damian (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Return to Week 3
Exercise 6.3 in Beginning Perl for Bioinformatics

#!/usr/bin/perl -w
use strict;

#Damian Almiron
#Ex 6-3

#Pseudocode:

#Use a subroutine to return the user's word.

#Main body:

#Ask the user to input any word.
#Write a message and insert the word provided by the user somewhere in the message.

##Subroutine
#Ask the user for a word.
#Collect the user's answer.
#Return the answer.

#Variables

my $word = 0;
my $message = "Please enter any adjective: ";

$word = userprompt($message);

print "You are a $word person.\n";

exit;


############
#Subroutine#
############

sub userprompt {

    my $message = @_;

    print "@_";

    my $word = <STDIN>;

    chomp $word;

    return $word;
}