Search code examples
perl

What does %$ mean in perl


I am trying to read a script that has a number of %$'s in it and despite a bunch of searching I haven't been able to find what they mean. Could someone please help me out?

Note: Apologies if this is a naïve question I'm not a perl dev I've just been asked to recreate a perl script in python. I have only very basic knowledge of the language.


Solution

  • If you have a reference to a hash (say in a variable called $hash_ref) then you put a % in front of it to dereference the hash reference and get back to the actual hash - %$hash_ref.

    See perlreftut for a tutorial on references in Perl.

    For future reference, it would be easier to help you if you included some samples of the actual code you are asking about.