/* Calming PerlMonks theme (c)2005 Radiantmatrix */ body { background: #cad3ea; color: #000; margin: 0; padding: 0; } a { text-decoration: underline; } a:link { color: #00d; background: transparent; } a:visited { color: #008; background: transparent; } .titlebar { background: #4b6bc5; color: #fff; } #mb2001titlebar{ padding-right: 6px; } .titlechooser { background: transparent;/* #6c799e; */ color: #00d; font-size: 110%; } .attribution { font-size: 9pt !important; font-family: sans-serif; } /*** Main Content Area ***/ .main_content { border-left: 1px solid #4b6bc5; border-right: 1px solid #4b6bc5; padding-left: 6px; padding-right: 6px; background: #eee; } .section_title { background: #4b6bc5 !important; color: #fff; } .codetext,.code,.inlinecode{ font-family: monospace; font-size: 100%; background: #cad3ea; } .readmore { border: 1px dotted #777; padding: 3px; } .code { display: block; white-space: pre; padding: 6px; margin: 12px; } .embed-code-dl { font-family: sans-serif; font-size: 90% } input[type=text],input[type=password],textarea { background : #ebf1ff !important; color : #000; border : 1px solid #8c9bc5; padding : 2px; } textarea { width: 95%; } thead, th { background: #4b6bc5 !important; color: #fff; } .vote, .reputation { font-family: sans-serif; font-size : 8pt !important; background : #ebf1ff; color: inherit; } .post_head { /* background: #4b6bc5 !important; */ background: #ccc !important; color: #eee; } /* .post_head a { color: #fff; background: transparent; } */ /** replies **/ #replies_table { background: #4b6bc5; font-size : 95% !important; } .reply-new-body, .reply-new-body p { font-size: 10pt !important; } .pmsig { border-top: 1px solid #cad3ea; } ins { border: 1px dotted #4b6bc5; border-top: 0 !important; text-decoration: none; } del { background: transparent; color: #999; border: 1px dotted #999; border-bottom: 0 !important; text-decoration: none; } /*** Nodelets ***/ .nodelet_container { font-size: 95%; font-family: sans-serif; width: 100%; } .nodelet_container, .nodelets, .nodelet_body_row, .nodebody, .nodebody td, .nodebody tr { background: #cad3ea !important; } .nodelets { border-right: 1px solid #4b6bc5; } .nodelet_head_row, .nodehead { background: #4b6bc5 !important; color: #fff; } /** Chatterbox **/ .chat { font-family: sans-serif; font-size : 90%; } td.highlight { background : #ebf1ff; color : inherit; } tr.highlight { background : #bbb; color : inherit; font-family: sans-serif; } #### # Accessing an attribute inside a traditional object $self->{ attribute } = $value; # Accessing an attribute inside an inside-out object $attribute { id $self } = $value; #### package My::Person; use Class::InsideOut qw[public readonly private register id]; # declare the attributes readonly given_name => my %given_name; readonly family_name => my %family_name; public birthday => my %birthday; public phone => my %phone; private ssn => my %ssn; public position => my %position; # object constructor sub new { my $self = shift; register( $self ); $given_name{ id $self } = shift; $family_name{ id $self } = shift; $birthday{ id $self } = shift; $phone{ id $self } = shift; $ssn{ id $self } = shift; $position{ id $self } = shift; } #### use My::Person; my $manager = My::Person->new( 'Random', 'Hacker', '12/18/1987', '555-1212', 'CEO' ); print "Old phone is: ",$manager->phone(); $manager->phone('555-1313'); #set new phone number print "New phone is: ",$manager->phone(); #### $manager->{phone} = '555-1313'; #### protection accessor_name => my %attribute_variable; #### # $obj->public_attrib() accessor, $obj->public_attrib($value) mutator public public_attrib => my %public_attrib; # $obj->read_attrib() accessor, no mutator readonly read_attrib => my %read_attrib; # no accessor or mutator private priv_attrib => my %priv_attrib; #### sub sendPhoneToDirectory { # sends the phone number to the company directory, using SSN as # the key my $self = shift; my $dir = My::Directory->new(); my $entry = $dir->getEngtryBySSN( $ssn{ id $self } ); $entry->phone( $phone{ id $self } ); $entry->commit; } #### sub _set_birthday { # remember, $_ will contain the value passed to the mutator die "$_ is not a valid date" unless m{(\d{2})/(\d{2})/(\d{4})}; $_ = mktime(0,0,0,$2-1,$1-1,$3-1900); #pack it! } #### public birthday => my %birthday, { set_hook =>; \&_set_birthday }; #### sub _get_birthday { # remember, $_ will contain the value of the attribute $_ = strftime '%m/%d/%Y', localtime( $_ ); } #### public birthday => my %birthday, { set_hook => \&_set_birthday, # was already here get_hook => \&_get_birthday, };