Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: @array elements multiplication with another array elements.

by Pizentios (Scribe)
on Oct 30, 2012 at 18:37 UTC ( #1001535=note: print w/replies, xml ) Need Help??

in reply to @array elements multiplication with another array elements.

use warnings; use strict; my @array1 = (3,4,6,5,8); my @array2 = (2,2,4,5,1); my $num = scalar @array1; my @answers; for (my $x = 0; $x < $num; $x++) { push(@answers, $array1[$x]*$array2[$x]); }

Replies are listed 'Best First'.
Re^2: @array elements multiplication with another array elements.
by 2teez (Priest) on Oct 30, 2012 at 18:50 UTC

    Or use a for ( or foreach ) loop like so:

    my @answers; for my $x ( 0 .. $#array1 ) { push @answers, $array1[$x] * $array2[$x]; }

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001535]
Discipulus needs to virtualize a xp home machine..
[Discipulus]: someone has experience with this? as destiation i think i'll go with virtualbox on centos
[Lady_Aleena]: Why XP?
[Discipulus]: it is for my father: it is impossible to tell him to learn a newer OS
[Lady_Aleena]: To tell him or teach him?
Discipulus anyway xp is still the best lowend game machine
[Discipulus]: both: everyting must be identical in the new v-machine
[Lady_Aleena]: So putting a nice DE or WM up on a Linux machine is not an option?
[Discipulus]: i need some converter to have directly an OVF format directly: at the moment i'm trying with vmware converter standalone

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2017-05-22 18:36 GMT
Find Nodes?
    Voting Booth?