Hi Monks, I'm a total newbie to perl, please be gentle on me. :-) (I'm reading Learning Perl at the moment.) I'm trying to fill an array with numeric data to use in my program, but 'warnings' say:
Argument "42 32 22" isn't numeric in multiplication (*) at ./multigear +.pl line 19, <STDIN> line 3. Argument "11 13 15 17 19 21" isn't numeric in division (/) at ./multig +ear.pl line 19, <STDIN> line 3. Use of uninitialized value in division (/) at ./multigear.pl line 20, +<STDIN> line 3. Illegal division by zero at ./multigear.pl line 20, <STDIN> line 3.
Below is my program, (which I will try to build & use nested loops in, when I can get it functioning).
#!/usr/bin/perl use strict; use warnings; print "\nMulti Gear Calculator\n\n"; print "Enter Wheelsize (inches): "; my $wheel = <STDIN>; #my $wheel = 26.5; chomp$wheel; print "Enter Chainwheel Teeth: "; my @chwhs = (<STDIN>); ###my $line; ###while($line = <STDIN>) { chomp $line; last unless $line =~ /\d/; pu +sh @chwhs, $line } #my @chwhs = qw (42 32 22); chomp@chwhs; print "Enter Cog Teeth: "; my @cogs = (<STDIN>); #my @cogs = qw (11 13 15 17 19 21 24 28 32); chomp@cogs; my $gear1 = $wheel*$chwhs[0]/$cogs[0]; my $gear2 = $wheel*$chwhs[0]/$cogs[1]; my $gear3 = $wheel*$chwhs[0]/$cogs[2]; my $gear4 = $wheel*$chwhs[0]/$cogs[3]; my $gear5 = $wheel*$chwhs[0]/$cogs[4]; my $gear6 = $wheel*$chwhs[0]/$cogs[5]; my $gear7 = $wheel*$chwhs[0]/$cogs[6]; my $gear8 = $wheel*$chwhs[0]/$cogs[7]; my $gear9 = $wheel*$chwhs[0]/$cogs[8]; my $gear10 = $wheel*$chwhs[1]/$cogs[0]; my $gear11 = $wheel*$chwhs[1]/$cogs[1]; my $gear12 = $wheel*$chwhs[1]/$cogs[2]; my $gear13 = $wheel*$chwhs[1]/$cogs[3]; my $gear14 = $wheel*$chwhs[1]/$cogs[4]; my $gear15 = $wheel*$chwhs[1]/$cogs[5]; my $gear16 = $wheel*$chwhs[1]/$cogs[6]; my $gear17 = $wheel*$chwhs[1]/$cogs[7]; my $gear18 = $wheel*$chwhs[1]/$cogs[8]; my $gear19 = $wheel*$chwhs[2]/$cogs[0]; my $gear20 = $wheel*$chwhs[2]/$cogs[1]; my $gear21 = $wheel*$chwhs[2]/$cogs[2]; my $gear22 = $wheel*$chwhs[2]/$cogs[3]; my $gear23 = $wheel*$chwhs[2]/$cogs[4]; my $gear24 = $wheel*$chwhs[2]/$cogs[5]; my $gear25 = $wheel*$chwhs[2]/$cogs[6]; my $gear26 = $wheel*$chwhs[2]/$cogs[7]; my $gear27 = $wheel*$chwhs[2]/$cogs[8]; my @gear1 = ($gear1, $gear2, $gear3, $gear4, $gear5, $gear6, $gear7, $ +gear8, $gear9); my @gear2 = ($gear10, $gear11, $gear12, $gear13, $gear14, $gear15, $ge +ar16, $gear17, $gear18); my @gear3 = ($gear19, $gear20, $gear21, $gear22, $gear23, $gear24, $ge +ar25, $gear26, $gear27); print "\nYour gears are:\n\n"; print "\nYour gears are:\n\n"; print "Wheelsize: $wheel\n"; print "Chainwheels: @chwhs\n"; print "Sprockets: @cogs\n\n"; print "@gear1\n\n"; print "@gear2\n\n"; print "@gear3\n\n";
This program should calculate cycle gear ratios from input entered from the keyboard. I have tried different ways to get the data, to no avail. Using data coded into the program, everything works fine. Can someone please point out my mistake(s).

In reply to 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.