After some friendly input from  yitzle I might have moved further with
my library.

This is my script.

script.pl


#!/usr/bin/perl

#require 'lib.pl';

@userArray = <STDIN>;

$sum = sumIt(@userArray);

print $sum;

And this is my library according to yitzle:


sub sumIt(@)
{
 my $total = 0;
 $total += $_ for (@_);
 return $total; # This line might not be needed...
}

sub avg(@)
{
 my @arr = @_;
 my $arrSize = @arr; # scalar(@arr) is the array size - or one less
(last index). Double check
 return simIt(@arr) / $arrSize;
}

1;

Now either this is wrong or I have no idea how to use it.

With STDIN I need to do something like this (right?):

./script.pl | echo 1234

Or is this nonsensical? Very very new to Perl.

Thanks

Amichai

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to