Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Object and tied hash all at once?

by btrott (Parson)
on Jul 07, 2001 at 00:54 UTC ( #94606=note: print w/replies, xml ) Need Help??


in reply to Object and tied hash all at once?

Yes, this is possible. Tie::SecureHash is an example of a class that does this.

In order to get the object and tied hash interface all at once, though, you have to be slightly tricky, and you need to create your object using the object constructor interface, not the tie interface:

sub new { my $class = shift; tie my %self, $class; bless \%self, $class; }
That returns a reference to the tied hash, which is also an object that is blessed into $class, which means that you can either use it as a tied hash, *or* call methods on it.

(NOTE: In the above example, the object is blessed into the tie class, but this is not required.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://94606]
help
Chatterbox?
[Discipulus]: ;=) I will unavailable this week during eu morning time: I'm following a redhat 7 basci course, finally
[1nickt]: bravo
[jedikaiti]: wheee
[Discipulus]: bravo the $employer who pay 1.340 neuros + vat ;=)
[Discipulus]: but i'd need 2 courses o acces the first lvl examen: they didnt pay it this year
[1nickt]: damn. pricey. I would have said there's not much to learn but apt-get, and do everything else in Perl ... but maybe I am forgetting some of the learning curve ;-)
[Discipulus]: the teacher is a python programmer.. ;=) he said it was fshion when he had to choose..

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-12-11 17:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (308 votes). Check out past polls.

    Notices?