Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates > by-pkgid > 1a3629464b9b5ca6d71831aa6f1473b2 > files > 56

perl-Mouse-0.58-1.fc13.i686.rpm

#!perl
package IntStack;
use Mouse;

has storage => (
    is => 'ro',
    isa => 'ArrayRef[Int]',

    default => sub{ [] },
    traits  => [qw(Array)],

    handles => {
        push => 'push',
        pop  => 'pop',
        top  => [ get => -1 ],
    },
);

__PACKAGE__->meta->make_immutable();

package main;

my $stack = IntStack->new;

$stack->push(42);
$stack->push(27);

print $stack->pop, "\n";
print $stack->top, "\n";