This is me just being a monkey and testing the script out:
F:\dev>perl fabric.pl How many fabrics are you using? 2 How wide is fabric 1? 1 To be safe, we'll use a width of -1 for fabric 1. How many different shapes of fabric 1 is a block made of? 1 What is the width of shape 1? 1 What is the height of shape 1? 2 Shape dimensions: The dimensions of shape 1 are 1x2 You can get 0 piece(s) of shape 1 per 1" strip of fabric 1. You can get 36 1" strips per yard. You can get 0 of shape 1 per yard of -1" of fabric 1. How many of shape 1 do you need per block? 23 You need 23 per block. How many blocks are you making? 2 You are making 2 blocks. You need 46 of shape 1. Illegal division by zero at fabric.pl line 88, <STDIN> line 7. F:\dev>
I'll update this node after I've messed with the code.

My monkeying around immediately proves insightful into how you can improve this (at least it appears so to me).

A good strategy might be to turn this into a module, and then, write "interfaces" for it, like commandline, CGI, GUI. All I have to say at this point is, not bad quiltmaker (some of your math may be funny, but useful to real people and immensly perlmonkish -- no prog/perl bg, good practices at the beginning). I see sanity checks, units of measurement conversions, price estimation.... ;D

update:

#!/usr/bin/perl -w use strict; # How many fabrics are you using? my $number_of_fabrics; print "How many fabrics are you using? \n"; chomp($number_of_fabrics = <STDIN>); $number_of_fabrics =~ s/\D//; # only allow number input ## $number_of_fabrics ||= 3; # assume default quietly unless($number_of_fabrics and $number_of_fabrics >=3 ) { warn "Ahem!!! You must enter a NUMBER >= 3, but that's ok, default + is 3"; $number_of_fabrics = 3; } #... more to come ... ;D

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


In reply to (crazyinsomniac:) Re: Fabric calculator - a better way to do it? by crazyinsomniac
in thread Fabric calculator - a better way to do it? by ailie

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.