Skeeve is absolutely correct in his statement. I would recommend the following:
- Pick a representation to use internally. I would make one up, probably along the lines of:
- Key
- Octave (from some default ... can be negative)
- Note number
The point here is to make it easy for you to do manipulation on the note.
- Figure out how to convert between your representation and some other representation
- Encapsulate that knowledge in some object that is different from your note representation. Have a Converter that will take a Note and return a string or take a string and return a Note.
The way to think about this is to consider Date::Calc or Date::Manip, two standard date manipulation modules. You give them a date string in pretty much any format and they will parse it. You can then manipulate it in nearly any way you can think of. You can then ask for the date back in pretty much any format.
The point here is that Date::Calc doesn't store weekdays as Monday, Tuesday, etc. It stores them as 1, 2, etc. But, it knows how to convert Day 1 to Monday (or lundi, or Mon, or whatever.), or vice versa. That's what you should strive for.
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.