Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

(crazyinsomniac:) Re: Fabric calculator - a better way to do it?

by crazyinsomniac (Prior)
on Dec 06, 2001 at 11:42 UTC ( #129865=note: print w/replies, xml ) Need Help??

in reply to Fabric calculator - a better way to do it?

This is me just being a monkey and testing the script out:
F:\dev>perl 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 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


#!/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

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

Replies are listed 'Best First'.
Re: (crazyinsomniac:) Re: Fabric calculator - a better way to do it?
by ailie (Friar) on Dec 06, 2001 at 12:19 UTC

    Wow. It never even occurred to me to put in widths like that, since quilting fabric is almost always 45" wide, sometimes 60" wide - certainly not 1" wide. Of course, now I'm going "D'oh!"

    The math is inelegant, but that's a basic fact of calculating fabric yardages for quilts. Simple math, but annoying.

    I like the module idea. Of course, I have no idea how to go about such a thing, but learning is really the whole point.

    Price estimation is simple:
    print "No, you may not buy more fabric. \n";

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://129865]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2023-06-05 22:20 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (26 votes). Check out past polls.