I'm writing a simple script in three different languages, Python, Ruby, and Perl. I'm extremely new to Perl, but really want to learn it. My problem being, I don't know how to write a method in Perl like in Ruby. I'm pretty sure that a method is called a function in Perl, but I'm not exactly sure..
Here's what I'm writing in the three languages: Ruby(all I have so far)
=begin
Test program to choose language
Ruby
creator Me
=end
def welcome
choices = %w(Perl Python Ruby)
lang = 3
puts "Welcome, to the test script, this will test what language you would like to learn.. In order to find out these choices, write this same definition in all three different languages"
puts "There are", lang, "languages to choose from please choose one:"
print choices
print ">\t"
input = gets.chomp
if input =~ /perl/i
puts "You have chosen Perl!"
elsif input =~ /python/i
puts "You have chosen Python!"
else
puts "You're already writing in Ruby!! Let me choose for you:"
print "#{choices.sample}\n"
end
end
welcome
As you can see this is a very simple script, I just feel as though writing it in three different languages will help me choose which one I want to learn next( I already know Ruby ).
Can someone explain to me how to write a method in Perl please? I've googled it but I can't seem to get anywhere with "method in Perl" It'd be greatly appreciated thank you ahead of time.