Hi manbroski,
"..Notice that I have to dereference it after the passage.." Why is that?
Did you also notice your subroutine sort_and_print_hash_keys definition
sub sort_and_print_hash_keys (\%) {..
and how you eventually used the it like so:
sort_and_print_hash_keys(%letters); # you passed a hash variable not a
+ hash ref.
".. But as far as the prototype passing, I was certain that it enforces a pass by reference..."
If I may suggest, you will do well yielding the wisdom of
jwkrahn, as regard the usage of prototype for this reason:
When you use a reference prototype, like "\$", "\@", "\%"
"...those symbols don't actually say that you must pass in a scalar reference, an array reference, and a hash reference. Rather, they say you must pass in a scalar variable, an array variable, and a hash variable. That means that the compiler insists upon seeing a properly notated variable of the given type, complete with "$", "@", or "%" in that slot. You must not use a backslash. The compiler silently supplies the backslash for you... "
from
Far More than Everything You've Ever Wanted to Know about Prototypes in Perl -- by Tom Christiansen -- by
liverpole, under subheading
Problems with Reference Prototypes
Hope this helps.
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author
unknown to me
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.