in reply to Re^3: Subroutine help
in thread Subroutine help

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.

Replies are listed 'Best First'.
Re^5: Subroutine help
by apl (Monsignor) on Aug 24, 2009 at 15:04 UTC
    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.