Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: How do you add class array values

by satchboost (Scribe)
on Apr 12, 2001 at 22:16 UTC ( [id://72127]=note: print w/replies, xml ) Need Help??


in reply to Re: How do you add class array values
in thread How do you add class array values

That would have to be push @{$this->{fields}}, $val. push requires a @-value, not a reference to a @-value, as its first argument.

On a more general note, the way to think about an object in Perl is that it's a hash that knows how to call functions. So, if you want to push a value onto an array and a reference to that array is stored in the object, you treat it just like an array. Using bless just means it knows how to call functions in a given package. (There's a little more to it, but that's basically the gist.)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-03-28 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found