Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-24 08:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found