Exercise 6.3D

From Earlham Cluster Department

Jump to: navigation, search

Return to Week 3
Exercise 6.3 in Beginning Perl for Bioinformatics</b>

#!/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;
}
<pre/>
Personal tools
Namespaces
Variants
Actions
websites
wiki
this semester
Toolbox