2008/9/8 Raul Ruiz Jr. <[EMAIL PROTECTED]>: > I am taking an online ceu course in scripting with Unix. I have been stumped > by this project. Can anyone out there help me out a bit. I created a script > at the bottom and it does not quite work. What am I missing?
Hello, Please always 'use strict' at your scripts. This can work: # cat t1.pl use strict; require 'lib.pl'; my @userArray = <STDIN>; my $sum = sumIt(@userArray); print $sum; # cat lib.pl use strict; sub sumIt(){ my @functionArray = @_; my $functionSum; foreach my $line (@functionArray){ $functionSum += $line; } return $functionSum; } 1; # perl t1.pl 1 2 3 4 (ctrl + D) The result is 10. The script t1.pl above reads arguments from STDIN, if you want to read from command line, then change the statement to: my @userArray = @ARGV; Good luck. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/