Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: how internally $#array is working in Perl

by JavaFan (Canon)
on Aug 13, 2010 at 08:23 UTC ( [id://854854]=note: print w/replies, xml ) Need Help??


in reply to how internally $#array is working in Perl

Please explain me about how $#array is internally working.
Not much magic going on. Internally, an array is represented by an AV structure (a C struct). The first field points to an xpvav structure (another C struct). Here, the second field, called FILL, is an integer holding the current size of the array.

The size of the array, plus the value of $[ is enough to calculate the size of $#array.

Illustrated details.

Replies are listed 'Best First'.
Re^2: how internally $#array is working in Perl
by ikegami (Patriarch) on Aug 13, 2010 at 16:22 UTC
    Actually, because $#array can be used as an lvalue, a fair bit of magic is going on (including adding "magic" to both the returned scalar and the array in some circumstances). Fortunately, it is invisible to the user.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-24 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found