in reply to What kind of code prints GLOB(hexaddress)

Hi Anonymous Monk.

I can understand how you feel. I have 'inherited' code written by co-workers ( past and present ) and the quality isn't always 'stellar' ( no documentation, large program with very few subroutines, etc. ).

#!/usr/bin/perl use strict; my @array = qw( perl is very cool ); my %hash = ( perl => "coder" ); print "\@array = ", ref( \@array ), "\n"; print "\%hash = ", ref( \%hash ), "\n"; print "\&subroutine = ", ref( \&subroutine ), "\n"; print "\*array = ", ref( \*array ), "\n"; sub subroutine { print "I'm a perl coder!\n"; }

Output:
@array = ARRAY %hash = HASH &subroutine = CODE *array = GLOB

The ref() function receives a reference argument and returns a string describing the type of reference passed to it. You are correct in assuming the hex number is a memory address. In 'C', this is essential when working with pointers but perl's use of references is safer and possesses improved stability.

Hope this helps,
-Katie.