Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Finding sum of numbers and storing it an Array

by hippo (Bishop)
on Sep 21, 2020 at 09:20 UTC ( [id://11121988]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @nums = (5, 10, 15, 20, 25);
    
  2. or download this
    my $totalSum = 0;
    $totalSum += $_ for @nums;
    
  3. or download this
    use List::Util 'sum';
    my $totalSum = sum @nums;
    
  4. or download this
    my @array = map { $_ / $totalSum } @nums;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-24 19:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found