sub split {
Do you really want to call this split()? IMHO it's not a good idea, I recommend you try something along the lines of mysplit() instead.
my %key; if ($_[0] =~ /^(.+?):(.+?)$/) {
This may be largely a matter of personal preferences, but I think you'd be better off shift()ing 'into' a more descriptive variable (or maybe a local()ised $_).
$key{'name'} = $1; $key{'definition'} = $2; $key{'altdefinition'} = '';
Also you may use the match operator's return value in list context. Maybe you knew and maybe you didn't. No harm done mentioning the possibility, IMHO.
} elsif ($_[0] =~ /^(.+?)\|(.+?)$/) { $key{'name'} = $1; $key{'altdefinition'} = $2; $key{'definition'} = '';
In my personal experience I find that in Perl cascaded elseifs are seldom really necessary and in general they also rarely add to clarity or conciseness.

I may be wrong, but couldn't you choose just one separator? Also I think you'd be better off using a real split() on such a separator (and possibly do some checks on the return values, e.g. to avoid 'uninitialized' warnings)...

What characters should i choose to be delimeters, and how could this be made "foolproof"?
You cannot make it foolprof for as soon as you'll think you have, along a better fool will come!

In reply to Re: Getting regular expression right by blazar
in thread Getting regular expression right by mellin

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.