Difference between revisions of "Exercise 6.3D"

From Earlham CS Department
Jump to navigation Jump to search
(New page: Return to Week 2 <br> Exercise 6.3 in <i>Beginning Perl for Bioinformatics</i></b> <pre> #!/usr/bin/perl -w use strict; #Damian Almiron #Ex 6-3 #Pseudocode: #Use a subroutine to re...)
 
 
Line 1: Line 1:
Return to [[Week 2]]
+
Return to [[Week 3]]
 
<br>
 
<br>
 
Exercise 6.3 in <i>Beginning Perl for Bioinformatics</i></b>
 
Exercise 6.3 in <i>Beginning Perl for Bioinformatics</i></b>

Latest revision as of 11:44, 18 December 2009

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;
}