[ create a new paste ] login | about

Link: http://codepad.org/bNJMRusI    [ raw code | output | fork ]

Perl, pasted on Nov 2:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;

package myparent;
{
    sub new
    {
        my $class = shift;
        my $self = { };
        bless $self, $class;
        $self->{listref} = eval '$' . $class . '::listref';
        return $self;
    }
}

package mychild;
{
    use base 'myparent';
    
    our $listref = [ 1, 2, 3 ];
}

package main;
{
    my $obj = mychild->new;

    print Dumper $obj;
}


Output:
1
2
3
4
5
6
7
$VAR1 = bless( {
                 'listref' => [
                                1,
                                2,
                                3
                              ]
               }, 'mychild' );


Create a new paste based on this one


Comments: