in reply to ...unblessed reference...

You should also put your print "New student created, we have ", ++$students, " students.\n"; outside of the anonymous subroutine. The way it is done now, you increase the number of students with each set-method called upon a Student object.

It is the first time I see an object constructor that returns a blessed code reference. I really wonder what special benefit this has over the more usual blessed hash. Care to enlighten me?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: ...unblessed reference...
by jdporter (Paladin) on Jul 16, 2012 at 20:26 UTC

    Data encapsulation/privacy. It means no calling code can snoop on the object's data by doing $obj->{'member'}.

      I have always found this encapsulation / privacy thing vastly overrated. If people want to snoop inside your objects (and discover the data they themselves previously put inside the object) and possibly mess up everything, then it is their responsibility, isn't it?

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics
        PadWalker FTW. Perl isn't C++. If you want privacy for proprietary software, compile an XS module. Even C/C++ won't stop a determined adversary. For example, in a callback, peeking at the C stack of your caller to get the job done. I've heard that being done in Windows land to get file handles which MS's API doesn't expose to callbacks yet are necessary to know. All the pitfalls aside.