Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^2: Help with arrays

by perlguru22 (Acolyte)
on Sep 22, 2012 at 06:27 UTC ( #995056=note: print w/replies, xml ) Need Help??

in reply to Re: Help with arrays
in thread Help with arrays

I think I Finally figured it out =)
#!/usr/bin/perl use warnings; $sum = 0; @nums = (); push (@nums,(4,4)); $sum += $_ for @nums; $size = @nums; $average = $sum / $size; print "$average";
This worked I am not sure if it's the correct way but it gave me the average

Replies are listed 'Best First'.
Re^3: Help with arrays
by Kenosis (Priest) on Sep 22, 2012 at 06:37 UTC

    Yes--well done!

    ...I am not sure if it's the correct way...

    Tim Toady!

    If I may, however, offer the following for you to consider:

    #!/usr/bin/perl use strict; use warnings; my $sum = 0; my @nums = (); push( @nums, ( 4, 8 ) ); $sum += $_ for @nums; my $size = @nums; my $average = $sum / $size; print "$average";
Re^3: Help with arrays
by Kenosis (Priest) on Sep 22, 2012 at 06:42 UTC

    My the above message.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995056]
[Discipulus]: i hope too, vacuum cleaner permitting, 2-3 afternoon to build. Or is the 1:1 serie? ;=)
[Tanktalus]: Sure, no one is active for hours and hours in the cb, so I go to upgrade the db, and then someone is active. Sheesh :)
[Discipulus]: anyway poppins probably died with the last night cold. But is not normal to see them in dec. they must pop in April
NodeReaper eyes the thorns in the side
Discipulus : the party puller!
[Discipulus]: I was trying to solve this but i'm not. my regex-fu is stuck at primary school

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-12-18 21:37 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (499 votes). Check out past polls.