Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Tiny Frameworks

by Ovid (Cardinal)
on Sep 29, 2007 at 18:25 UTC ( #641718=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    package My::UNIVERSAL;
    
    use base qw(Class::Data::Inheritable);
    
    1;
    
  2. or download this
    package My::UNIVERSAL;
    
    use strict;
    ...
    );
    
    1;
    
  3. or download this
    package Creature;
    
    use base 'My::UNIVERSAL';
    ...
        name   => 'Alice',
        gender => 'female',
    } );
    
  4. or download this
    $VAR1 = bless( {
      gender => 'female',
      name   => 'Alice'
    }, 'Creature' );
    
  5. or download this
    sub mk_accessors {
        my ( $class, @accessors ) = @_;
        foreach my $accessor (@accessors) {
    ...
            };
        }
    }
    
  6. or download this
    sub area {
        my $self = shift;
        return $self->height * $self->width;
    }
    
  7. or download this
    use Scalar::Util 'reftype';
    
    sub new {
    ...
        }
        return $self;
    }
    
  8. or download this
    $VAR1 = bless( {
      'Creature::gender' => 'female',
      'Creature::name'   => 'Alice'
    }, 'Creature' );
    
  9. or download this
    $creature->name('Bob')
             ->gender('unknown');
    
  10. or download this
    my $creature = Creature->new( {
        name   => 'Alice',
        gender => 'female',
        foo    => 1,
    } );
    
  11. or download this
    __PACKAGE__->mk_class_data('__data_key');
    
    sub new {
    ...
        return unless exists $self->{ $self->__data_key }->{$attribute};
        goto $check_attribute;
    }
    
  12. or download this
    package Creature;
    
    use base 'My::UNIVERSAL';
    ...
        $self->_must_have('name');
        $self->_may_have('gender');
    }
    
  13. or download this
    package IP::Address;
    
    use base 'My::Universal';
    ...
    
    my $ip = IP::Address->new({ ip => $some_ip });
    print $ip->address;   # prints $some_ip
    
  14. or download this
    my $check_keys = sub {
        my $self = shift;
        my $data = delete $self->{ $self->__data_key };
    ...
        $self->$check_keys;
        return $self;
    }
    
  15. or download this
    my $creature = Creature->new( {
        name   => 'Alice',
        gender => 'female',
    ...
    } );
    
    # Unknown keys to constructor:  (bar, foo)
    
  16. or download this
    package Tall::Square;
    
    use Scalar::Util 'looks_like_number';
    ...
    }
    
    1;
    
  17. or download this
    package My::UNIVERSAL;
    
    use strict;
    ...
    }
    
    1;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://641718]
Front-paged by lidden
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-07-07 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls