Hi Monks,

As pointed out to me in Re^3: Turning foreach into map?, I should really be trying to learn refs instead of map just now.

I have been reading perlreftut, and started to get an idea for the first program I want to write to learn refs.

The program will simply ask for some food types and tell you if you can eat them together, according to a combination chart (This is taken from the, "You Are What You Eat Cookbook").

Following the example, I have a data format as follows (HoAs?) and I just want to check this is correct before moving on to the code:

%food_combining ---------------- proteins ---->| Cheese | Eggs | Fish | Game | Rabbit + | Meat | Milk | Nuts | Poultry | Shellfish | Soybeans | tofu | soya +| Yogurt carbohydrates ---->| oats | pasta | rice | rye | maize | m +illet | biscuits | bread | cakes | crackers | pastry | honey | maple +syrup | potatoes | yams | sweetcorn | sugar | sweets nonstarchy_veg_and_fats ---->| Butter | Cream | Herbs | Spices | Sea +sonings | Olive Oils | Oils | Salads | Seeds Fruit ---->| All Fruit

The rules, once someone enters something via <STDIN>, are:

Yes: Groups 1 and 3 Groups 2 and 3 Group 4 alone No: Groups 1 and 2 Groups 1 and 4 Groups 2 and 4 Groups 3 and 4

If so, I'll start writing.

Thanks.

Walking the road to enlightenment... I found a penguin and a camel on the way.....
Fancy a yourname@perl.me.uk? Just ask!!!

In reply to Continuing from "Turning foreach into map?" - perlreftut and References by ghenry

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.