"Sputnik" help  
Sputnik Help
Language Reference - Classes - Class Magic Functions - Sleep

Class Magic Functions - Sleep

Called when a class is serialized.

// define a class
class test
{
    my $x;
    Function __Construct($a)
    {
        $x = $a;
    }
    Function __Sleep()
    {
        say "The class has been serialized";
    }
    Function __WakeUp()
    {
        say "The class has been unserialized";
    }
}

// create new instance
my $a = new test(20);

// serialize the class
my $ser = Serialize($a);

// nnserialize the class
my $b = Unserialize($ser);

// print value
say $b->$x;

// PRINTS
// The class has been serialized
// The class has been unserialized
// 20

A full list of all possible magic functions can be found here.


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org