For the sake of efficiency, you will probably want to go with
code that looks a lot like the snippet submitted by
btrott
although i think that this might be more similar to your
initial posting. I added some extra whitespace matches, just
because users are typically stupid.
if ($current_input =~ /^\s*ca\s+(\w+)\s*->\s*(\w+)\s*$/) {
my ( $key, $value ) = ($1, $2);
$aliases{$key} = $value;
}
The other thought which occurs to me, is how are you
attempting to retrieve the data back from the hash? You can
always perform a sanity check to make sure that there is
data in the hash.
foreach my $key (keys $aliases) {
print "\$aliases{$key} = $alias{$key}\n";
}
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.