Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Using OOP doesn't actually require packages and bless()ing. It just means you have to do something in an object-oriented way :)

With that in mind, it depends on what you're using the information *for*. For example, if you only need to process the color information for everything at once, using $color{'car'} and $color{'bike'} make perfect sense.

On the other hand, if you needed to keep the different attributes of an item together (for example, for storage to a file on disk), you might prefer to do this:

$car = { wheels => 4, doors => 4, color => 'blue', trans => 'auto' }; $bike = { wheels => 2, color => 'red', };
The reason for doing this is that, with all the attributes of an item in one hash, it's easy to pass that item around to whatever might need it. For example, you can pass it to Storable's freeze method and preserve your car in a disk file (for thawing by another script, or a later instance of your own). Or, you could pass a hash to a function that does something generic to whatever is passed in (like telling you if its turn signals automatically shut off; vehicles without steering wheels don't have that). This sort of design is at the heart of OO.
$"=$,,$_=q>|\p4<6 8p<M/_|<('=> .q>.<4-KI<l|2$<6%s!<qn#F<>;$, .=pack'N*',"@{[unpack'C*',$_] }"for split/</;$_=$,,y[A-Z a-z] {}cd;print lc

In reply to Re: When hashes aren't enough by Stevie-O
in thread When hashes aren't enough by Sprad

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (6)
    As of 2018-08-21 23:11 GMT
    Find Nodes?
      Voting Booth?
      Asked to put a square peg in a round hole, I would:

      Results (204 votes). Check out past polls.