Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on


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... "
-- 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

In reply to Re^3: Entering the land of Perl by 2teez
in thread Entering the land of Perl by manbroski

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • 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?
    As of 2014-12-28 17:12 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (182 votes), past polls