HackerTrans
TopNewTrendsCommentsPastAskShowJobs

vilhelmen

no profile record

comments

vilhelmen
·9개월 전·discuss
Something I've long appreciated is a little Perl script to compute statistics on piped in numbers, I find it great for getting quick summaries from report CSVs.

    #!/usr/bin/perl
    # http://stackoverflow.com/a/9790056
    use List::Util qw(max min sum);
    @a=();
    while(<>){
        $sqsum+=$_*$_;
        push(@a,$_)
    };
    $n=@a;
    $s=sum(@a);
    $a=$s/@a;
    $m=max(@a);
    $mm=min(@a);
    $std=sqrt($sqsum/$n-($s/$n)*($s/$n));
    $mid=int @a/2;
    @srtd=sort @a;
    if(@a%2){
        $med=$srtd[$mid];
    }else{
        $med=($srtd[$mid-1]+$srtd[$mid])/2;
    };
    print "records:$n\nsum:$s\navg:$a\nstd:$std\nmed:$med\max:$m\nmin:$mm";
vilhelmen
·2년 전·discuss
I've been using it for what must be over ten years and I cannot recommend it enough, especially given how poor searching for anything on Windows is now.