Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Unscalar'ize a fake array

by karlgoethebier (Abbot)
on Sep 17, 2017 at 13:55 UTC ( [id://1199553]=note: print w/replies, xml ) Need Help??


in reply to Unscalar'ize a fake array

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1199553]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-19 10:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found