in reply to routine as subroutine and on command line

$ perl -e '$n++, $sum += $_ while <>; print $sum/$n,$/' some_file_holding3numbers.txt

That assumes the numbers are one to a line in the file

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: routine as subroutine and on command line
by blakem (Monsignor) on Jan 19, 2002 at 00:14 UTC
    fore!
    % perl -ple'$;+=$_}{$_=$;/$.' 3numbers.txt

    -Blake