With the help of, & grateful thanks to Gangabass, Athanasius, GrandFather, philiprbrenan, & ww.
I offer my first proper Perl program to anyone who may like to use it.
Cycle Gear Ratio Calculator
#!/usr/bin/perl
use strict;
use warnings;
my $fh = \*STDIN; # For test input, change to: \*DATA
###my $fh = \*DATA; # For user input, change to: \*STDIN
print "\nMulti Gear Calculator\n\n";
print "Enter Wheelsize (inches): ";
my $wheel = <$fh>;
print $wheel;
chomp $wheel;
print "Enter Chainwheel Teeth: ";
my $chainWheels = <$fh>;
print $chainWheels;
my @chainWheels = split /\s+/, $chainWheels;
print "Enter Cog Teeth: ";
my $cogs = <$fh>;
print $cogs;
my @cogs = split /\s+/, $cogs;
print "Wheelsize: $wheel\n";
print "Chainwheels: @chainWheels\n";
print "Cogs: @cogs\n\n";
for my $chainSel (1 .. @chainWheels) {
my $wheelMul = $wheel * $chainWheels[$chainSel - 1];
print "Chain wheel: $chainSel ratios: \n";
for my $cogSel (1 .. @cogs) {
printf "%5.2f ", $wheelMul / $cogs[$cogSel - 1];
}
print "\n";
}
__DATA__
26.5
42 32 22
11 13 15 17 19 21 24 28 32
-
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.
|