Exercise 6.3D
Jump to navigation
Jump to search
Return to Week 2
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; }