Please consider using for loops to simplify your array assignment logic to reduce the possibility of mistakes. pp() is very useful for checking that everything has worked as expected.

use feature ":5.14"; use warnings FATAL => qw(all); use strict; use Data::Dump qw(dump pp); my $wheel = 2100; my @chwhs = qw (23 26 27); # test data my @cogs = qw (11 13 15 17 19 21 24 28 32); # test data my $gear; for my $c(0..2) {$gear->[$c][$_] = $wheel*$chwhs[$c]/$cogs[$_] for 0..8; } pp($gear);

Produces

[ [ "4390.90909090909", "3715.38461538462", 3220, "2841.17647058824", "2542.10526315789", 2300, "2012.5", 1725, "1509.375", ], [ "4963.63636363636", 4200, 3640, "3211.76470588235", "2873.68421052632", 2600, 2275, 1950, "1706.25", ], [ "5154.54545454546", "4361.53846153846", 3780, "3335.29411764706", "2984.21052631579", 2700, "2362.5", 2025, "1771.875", ], ]

In reply to Re: I'm trying to get a numeric array by philiprbrenan
in thread I'm trying to get a numeric array by fatmac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.