Csonytii has asked for the wisdom of the Perl Monks concerning the following question:
Well, i understand what pieces i am using but i wonder the logic behind it.#!/usr/bin/perl -w $sum=0; $count=0; open(INPUT,"meres.txt") or die "ERROR"; while($line=<INPUT>) { chomp($line); if($line=~/([-\d]+(\d+)*)/){ #print($1."\n"); $sum+=$1; $count++; } } close(INPUT); print $sum/$count; print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why this is work?
by Veltro (Hermit) on May 29, 2018 at 12:59 UTC | |
by Csonytii (Novice) on May 29, 2018 at 13:16 UTC | |
|
Re: Why this is work?
by pme (Monsignor) on May 29, 2018 at 12:52 UTC | |
by Csonytii (Novice) on May 29, 2018 at 13:19 UTC | |
|
Re: Why this is work?
by Jenda (Abbot) on May 31, 2018 at 15:32 UTC | |
by Your Mother (Archbishop) on May 31, 2018 at 16:10 UTC | |
by Jenda (Abbot) on Jun 04, 2018 at 09:18 UTC | |
|
Re: Why this is work?
by locked_user sundialsvc4 (Abbot) on May 29, 2018 at 14:30 UTC | |
by Jenda (Abbot) on May 30, 2018 at 12:33 UTC | |
by Anonymous Monk on May 30, 2018 at 16:22 UTC |