in reply to Re: Subroutine help
in thread Subroutine help

Hi, Thank you very much for your help. It works now, but it doesnt let me input the numbers into the parameter, it always equals to 21. I need to be able to input numbers. Thanks to everyone for all your help. :D

Replies are listed 'Best First'.
Re^3: Subroutine help
by apl (Monsignor) on Aug 23, 2009 at 15:10 UTC
    Where's your code to prompt for and read the six numbers? We can't help you if you don't show us your code.
      use strict; use warnings; sub AddNumbers { my ($first_number, $second_number, $third_number, $fourth_number, +$fifth_number, $sixth_number) = @_; my $add = $first_number + $second_number + $third_number + $fourth +_number + $fifth_number + $sixth_number; return $add; } my $sum = AddNumbers( 1, 2, 3, 4, 5, 6 ); print "The sum of input numbers equals to: $sum \n";
      Heres the code, i want to be able to get input from user and get them added and output to be shown.
        I was not clear; sorry.

        You specify my $sum = AddNumbers( 1, 2, 3, 4, 5, 6 ); As a result, you will always get 21 as an answer.

        If you ever hope to see a different answer, you need to specify six variables (or an array of values). In order to do that, you need to prompt the user for the values, and then inout those values.

        If you want us to help you fix the software that does that, you need to show us the software first. The code you reposted does not prompt the user, neither does it input anything.