Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: while going through perldsc tutorial...

by philcrow (Priest)
on Oct 16, 2007 at 19:41 UTC ( #645264=note: print w/replies, xml ) Need Help??


in reply to while going through perldsc tutorial...

In the line marked #WRONG, the reference is always taken to @array which is only allocated once in the program (probably implicitly). Therefore, on each iteration, @array gets new values, and its location gets stored and all those references refer to the last set of values. To fix it, declare @array on each iteration:
my @array = somefunc($i);
Then, new memory is allocated each time and the references are to those different memory areas.

Phil

The Gantry Web Framework Book is now available.

Replies are listed 'Best First'.
Re^2: while going through perldsc tutorial...
by convenientstore (Pilgrim) on Oct 16, 2007 at 21:27 UTC
    i understand now.. thank you

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://645264]
help
Chatterbox?
[erix]: I recognise the makings of a fine argument
[LanX]: lanx wonders ... how likely is it to talk >95% BS without intention?
[erix]: "gigantic amounts of data" is also not SQLite (imho)
talexb wonders why sqlite2 was deprecated in favour of sqlite3.
[erix]: looks like a fork, rather, no?
LanX /me /me

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (12)
As of 2017-07-28 15:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (431 votes). Check out past polls.