Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: What kind of code prints GLOB(hexaddress)

by DigitalKitty (Parson)
on Jun 06, 2003 at 20:18 UTC ( [id://263841]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-26 01:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found