--- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > Your problem is that you are using the $! variable: > > But you are using it for a pattern match failure > which is neither a system nor > a library call. > > > my @numbers = split( / /, $userIn ); > > I would write that as: > > my @numbers = $userIn =~ /\d+/g; > @numbers or die "Please, enter numbers separated by > spaces only!"; > Yep. Actually, I had already followed your suggestion, with the addition of "\n". But, it was to get rid of the fact that "$!" was spitting out the file name. Thanks, for an explaination behind the *real* reason I should make the change. > > > my $total = scalar( @numbers ); > > "my $total =" forces scalar context so using the > scalar() function is redundant.
Thanks, I shortened this up too; scalar function gone. [pg. 73 "Camel Book] > > > But since you are sorting numbers, you probably want > to do a numeric sort to > get the correct numbers: > > my ( $smallestNum, $largestNum ) = sort { $a <=> $b > } @numbers; > I'm using: my @sorted = sort { $a <=> $b } @numbers; Thanks, again. [pg. 790 "Camel Book"] This was overlooked in my haste. > > > my $sum = 0; > > foreach ( @numbers ) { > > $sum += $_; > > } > > > > my $average = ( $sum / $total ); > > You could just use the array there as a mathematical > expression forces scalar > context: > > my $average = ( $sum / @numbers ); > This is bookmarked for future reference. Thanks, a lot John. :-) Ron Smith [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>