For the fearless:
#!/usr/bin/env perl # $Id: 1199549.pl,v 1.2 2017/09/17 13:01:45 karl Exp karl $ # http://perlmonks.org/?node_id=1199549 use strict; use warnings; use Data::Dump; use List::Util qw(sum); use feature qw (say); my $result = '2017-08-01 20MICRONS 37744 + 2016-08-01 20MICRONS 25966 + 2016-04-20 20MICRONS 30807 + 2016-04-01 20MICRONS 32780'; my @numbers = grep { /\d{5}/ } split /[\n,\s]/, $result; say sum (@numbers) / scalar @numbers; __END__
Minor update: Fixed dumb typo in regex..
Update: And see also Re^2: Best way to sum an array?...
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help
In reply to Re: Unscalar'ize a fake array
by karlgoethebier
in thread Unscalar'ize a fake array
by Gtforce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |